我在winfrom程序里写的一段代码:请看下为什么还是没走locatedata1 这个方法
private void Form1_Load(object sender, EventArgs e)
{
GrapeCity.ActiveReports.PageReport rpt = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(@"PageReport1.rdlx"));
rpt.Document.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(locatedata1);
GrapeCity.ActiveReports.Document.PageDocument rpdt = new GrapeCity.ActiveReports.Document.PageDocument(rpt);
this.viewer1.LoadDocument(rpdt);
}
private void locatedata1(object cender, GrapeCity.ActiveReports.LocateDataSourceEventArgs args)
{
if (args.DataSourceName == "DataSource1")
{
if (args.DataSetName == "DataSet1")
{
args.Data = GetData();
}
}
}
private DataTable GetData()
{
DataTable dt = new DataTable();
dt.Columns.Add("Col1");
dt.Columns.Add("Col2");
dt.Columns.Add("Col3");
dt.Rows.Add(1, 1, 1);
dt.Rows.Add(2, 1, 1);
dt.Rows.Add(3, 1, 1);
dt.Rows.Add(4, 1, 1);
dt.Rows.Add(5, 1, 1);
dt.Rows.Add(6, 1, 1);
return dt;
} |