一、 新建XtraForm(可增加printBarManager1打印控件)

二、引用类using DevExpress.XtraReports.UI;//使用报表属性需要用到该类

//实例化打印报表
 public Reports.XtraReport_ZD rpt = new Reports.XtraReport_ZD();

三、首先在XtraReportBase.Bands属性中添加Bands(添加带区)

ReportHeaderBand header = new ReportHeaderBand();//表头(一次)
 //把带区加到报表中
rpt.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] { detail, header, pagefood, topM, ghBand });

四、 在相应的Bands的XRControl.Controls属性中添加控件(往相应的带区添加控件)

//新增控件,设定控件的属性
XRLabel xlabRH = new XRLabel();
xlabRH.Text = "表头";
xlabRH.BackColor = Color.SeaGreen;
xlabRH.Font = new Font(new System.Drawing.FontFamily("宋体"), 20, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
 xlabRH.Size = new Size(200, 42);//设置控件大小
xlabRH.LocationF = new System.Drawing.Point(100, 500);
//把控件添加到带区
rpt.Bands[BandKind.ReportHeader].Controls.Add(xlabRH);
View Code

相关文章: