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。 –