【发布时间】:2010-04-24 09:34:21
【问题描述】:
我创建了我的报告,但我似乎无法将报告查看器与报告源绑定?我认为他们改变了做事的方式?
【问题讨论】:
标签: c# wpf visual-studio-2010 crystal-reports
我创建了我的报告,但我似乎无法将报告查看器与报告源绑定?我认为他们改变了做事的方式?
【问题讨论】:
标签: c# wpf visual-studio-2010 crystal-reports
来自 SAP 支持网站 http://forums.sdn.sap.com/message.jspa?messageID=8995372
//Using the ReportDocument SDK
this._report = new ReportDocument();
this._report.Load(@"C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\CrystalReportWpfApplication1\CrystalReportWpfApplication1\CrystalReport1.rpt");
this.reportViewer.ViewerCore.ReportSource = this._report;
【讨论】:
这可能是一个很晚的答案,但可能会帮助其他正在寻找类似问题的人。 如果要绑定 ReportSource,则需要将 CrystalReportViewer 控件包含在 UserControl 中的 WindowsFormsHost 中,并声明字符串类型的依赖属性。您需要从此处设置 ReportSource。您不能直接从 XAML 将其与本机控件绑定。
【讨论】:
我有同样的问题,但就像上一篇文章一样,我认为它可能对其他人有帮助。
用于 WPF 的 CrystalReportViewer 有一个名为“内容”的属性。这个 Content 属性实际上是一个 StackPanel,有 3 个孩子,第三个是这个新元素“ViewerCore”,它填充了 DockPanel 上的所有可用空间 (LastChildFill)。
ReportSource 属性在此 ViewerCore 中,因此要访问此 ViewerCore (ReadOnly) 属性,您需要执行以下操作:
添加对 SAPBusinessObjects.WPF.Viewer 的引用
添加 using 语句using SAPBusinessObjects.WPF.Viewer;
然后设置报表使用的来源
ViewerCore view = crReportViewer.ViewerCore; view.ReportSource = cryRpt;
HTH 诺艾尔
【讨论】: