1
在Windows窗体应用程序中,它与创建窗体并将RPT文件绑定到窗体一样简单。看起来这个选项对于WPF是不可能的。在WPF应用程序上显示水晶报表(Visual Studio 2008)
我想在单击按钮时在新窗口上显示Crystal Report。如何用WPF实现这一点。
在Windows窗体应用程序中,它与创建窗体并将RPT文件绑定到窗体一样简单。看起来这个选项对于WPF是不可能的。在WPF应用程序上显示水晶报表(Visual Studio 2008)
我想在单击按钮时在新窗口上显示Crystal Report。如何用WPF实现这一点。
它可以通过窗口类来完成:
见下面的代码演示
MyWindowType myReport = new MyWindowType(); // create a window, MyWindow is an User Control of type Window, that is it extends Window
MyCrystalReport myReport = new MyCrystalReport();
// Do necessary modifications to myReport such as Add Data and Send Parameters
CrystalReportViewer rptViewer = new CrystalReportViewer(); // Construct a ReportViewer
WindowsFormsHost host = new WindowsFormsHost(); // Create a WindowsFormsHost
rptViewer.ReportSource = myReport; // Add Report to ReportSource
host.Child = rptViewer; // Add report viewer as child to host
myReport.reportGrid.Children.Add(host); // Add host to MainWindow, that is myReport in this example
myReport.BringIntoView();
myReport.Show();
您使用的是什么版本的Visual Studio?如果VS2010,有一个WPF CrystalReportViewer可供下载。
我使用Visual Studio 2008。 –