我保存报告模板:
report.Save("C:\\kk.mrt");
然后我加载保存的报告并将其分配BusinessObjects为Dictionaries
StiReport rptLoad = new StiReport();
rptLoad.RegBusinessObject("Company", repository.GetAll<Company>());
rptLoad.Load("C:\\kk.mrt");
rptLoad.BusinessObjectsStore包含已注册的BusinessObjects刚刚注册 ( Watchedat RunTime) 但是:
rptLoad.Show();
如果保存的报告中包含
Bindings(如:):那么Components.Add(new StiText{Text="{Company.Name}"}得到我:
error CS0103: The name 'Company' does not exist in the current context否则,如果我没有
Bindings保存的报告:那么rptLoad.Show();将显示报告,但没有注册Dictionaries(当我在显示报告后进入设计模式时,我BusinessObjects在字典中没有看到)。如果我
rptLoad.Design();之前打电话rptLoad.Show();:那么
报告显示并且Bindings正常,我可以BusinessObjects在显示的报告中看到(在设计和预览模式下)。