在运行时将 RPX文件加载到报表的查看器中

1、右键点击Windows窗体并在右键菜单中选择查看代码选项用来切换到当前窗体的代码视图。

2、向类中添加如下代码用以加载一个报表。

Visual Basic.NET 代码

Dim rpt As New GrapeCity.ActiveReports.SectionReport()

 

Dim xtr As New System.Xml.XmlTextReader(Application.StartupPath + "\report.rpx")

rpt.LoadLayout(xtr)

xtr.Close()

Viewer1.Document = rpt.Document

rpt.Run()

 

C#代码

GrapeCity.ActiveReports.SectionReport rpt = new

GrapeCity.ActiveReports.SectionReport();

 

System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Application.StartupPath+ "\\Sample.rpx");

rpt.LoadLayout(xtr);

xtr.Close();

viewer1.Document = rpt.Document;

rpt.Run();