DevExpress.XtraReports根据窗体控件值来显示打印数据

例举如下:

DevExpress.XtraReports根据窗体控件值来显示打印数据_第1张图片

1、在上面窗口中,打印预览时,打印格式中显示的数据只是包含uName字段的值,则在Preview的单击事件中写
            XtraReport1 report = new XtraReport1();          
           (report.DataSource as CCDBDataSet).Tables[0].DefaultView.RowFilter = "uName like'"+"%"+textEdit1.Text +"%"+"'";  
            report.ShowPreview();


2、在上面窗口中,打印预览时,打印格式中显示的数据只是等于uName字段的值,则在Preview的单击事件中写

           XtraReport1 report = new XtraReport1();
           string uName= textEdit1.Text.Trim();
          //(report.DataSource as CCDBDataSet).Tables[0].DefaultView.RowFilter = "uName ='"+textEdit1.Text.Trim();
            (report.DataSource as CCDBDataSet).Tables[0].DefaultView.RowFilter = "uName =" + uName;
            //Show the report's preview.
            report.ShowPreview();


你可能感兴趣的:(C#.net,devexpress)