简体   繁体   English

Visual Studio 2010 Crystal Reports WPF

[英]visual studio 2010 crystal reports wpf

I created my report but I cant seem to bind the report viewer with the report source? 我创建了报告,但似乎无法将报告查看器与报告源绑定? I think they changed the way things are done? 我认为他们改变了工作方式?

From SAP support site http://forums.sdn.sap.com/message.jspa?messageID=8995372 从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;

This might be a very late answer, but might help others who are looking for a similar issue. 这可能是一个很晚的答案,但可能会帮助正在寻找类似问题的其他人。 If you want to Bind the ReportSource, You need to enclose the the CrystalReportViewer control within a WindowsFormsHost in a UserControl and declare a dependency property of type string. 如果要绑定ReportSource,则需要将CrystalReportViewer控件包含在UserControl的WindowsFormsHost中,并声明string类型的依赖项属性。 You need to set the ReportSource from here. 您需要从此处设置ReportSource。 You cannot directly bind it from XAML with the native control. 您不能直接从XAML将其与本机控件绑定。

I had the same problem but just like the last post I though it might be helpful to others. 我有同样的问题,但就像上一篇文章一样,尽管它可能对其他人有帮助。

The CrystalReportViewer for WPF has a property called "Content". WPF的CrystalReportViewer具有一个名为“内容”的属性。 This Content property is literally a StackPanel, with 3 Children, the third being this new element "ViewerCore", which fills all space available on the DockPanel (LastChildFill). 这个Content属性实际上是一个StackPanel,带有3个子级,第三个是这个新元素“ ViewerCore”,它填充了DockPanel(LastChildFill)上的所有可用空间。

The ReportSource property is in this ViewerCore, so to access this ViewerCore (ReadOnly) property, you need to do the following: ReportSource属性位于此ViewerCore中,因此,要访问此ViewerCore(ReadOnly)属性,您需要执行以下操作:

add a reference to SAPBusinessObjects.WPF.Viewer 添加对SAPBusinessObjects.WPF.Viewer的引用

add a using statement using SAPBusinessObjects.WPF.Viewer; using SAPBusinessObjects.WPF.Viewer;添加using语句using SAPBusinessObjects.WPF.Viewer;

and then to set the source of the report use 然后设置报告来源

ViewerCore view = crReportViewer.ViewerCore; view.ReportSource = cryRpt;

HTH Noelle HTH Noelle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM