在我的表单中,我具有以下代码,只需单击一下按钮即可打开报告:
private void btnGroupOther_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
LayoutControl lc = new LayoutControl();
lc.Dock = DockStyle.Fill;
DateEdit FirstDate = new DateEdit();
DateEdit LastDate = new DateEdit();
lc.AddItem(Resources.firstdate, FirstDate).TextVisible = true;
lc.AddItem(Resources.seconddate, LastDate).TextVisible = true;
lc.Height = 70;
this.Controls.Add(lc);
this.Dock = DockStyle.Top;
if (DevExpress.XtraEditors.XtraDialog.Show(lc, " ", MessageBoxButtons.OKCancel) == DialogResult.OK)
{
RepProductionGroupOther report = new RepProductionGroupOther();
report.DataSource = paint.RepProductionGroupOther(Convert.ToDateTime(FirstDate.EditValue).ToString("MM/dd/yyyy"),
Convert.ToDateTime(LastDate.EditValue).ToString("MM/dd/yyyy"));
report.ShowRibbonPreviewDialog();
}
}
在标题报告中,我有两个xrLabel
;第一个txtFirstDate
和第二个txtLastDate
。我想在FirstDate
中显示DateEdit
txtFirstDate
控件的值,在LastDate
中显示DateEdit
txtLastDate
控件的值。
我该怎么做,报表的数据源是sql存储过程。
它具有两个参数:@FirstDate
和@LastDate
。
预先感谢
答案 0 :(得分:0)
我建议您阅读XtraReport文档:
Request and Pass Report Parameter Values
private void button1_Click(object sender, EventArgs e) {
// Create a report instance.
XtraReport1 report = new XtraReport1();
// Obtain a parameter and set its value.
report.Parameters["parameter1"].Value = 30;
// Hide the Parameters' UI from end-users (if you did not hide it at design time).
report.Parameters["parameter1"].Visible = false;
// Show the report's print preview depending on your target platform.
// ...
}
检查上述文档中的“自定义参数编辑器”部分 参数的自定义编辑器实现取决于您的应用程序平台:
Windows窗体
在Windows Forms应用程序中,您可以在XtraReport.ParametersRequestBeforeShow事件处理程序中提供自定义参数编辑器。
有关代码示例,请参见Provide Custom Editors for Report Parameters。
下面是与您尝试执行的类似的实现。请检查这些内容,希望这将帮助您解决问题。
How to pass parameters to devexpress XtraReport from combobox
DevExpress XtraReport Setting a DateTime Parameter to Today