Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using MS ReportViewer in WPF

I'm about to start using the MS ReportViewer in a WPF application by placing the ReportViewer in a WindowsFormsHost.

Is this the correct approach? What is the best way of designing the reports as you cannot use the ReportViewer at design time in a WindowsFormsHost.

Is it best to create an RDL report in SQL Server and then convert it to an RDLC or maybe to create a new Winforms app to create an RDLC file in a WinForms framework and then copy it to the WPF app.

I will need to filter the reports via dropdowns so there's that aspect to consider too. If anyone out there is already using ReportViewer in WPF I would appreciate some feedback on the best approach.....Many thanks.

like image 293
Mitch Avatar asked May 07 '09 23:05

Mitch


People also ask

What is Microsoft ReportViewer?

Microsoft Report Viewer is a software that enables applications that run on the Microsoft . NET Framework to display reports designed using the Microsoft reporting technology.

What is Rdlc report in WPF?

RDLC stands for Report Definition Language Client Side. It is used to create reports the with the in-built services provided by Microsoft. Initially, RDLC was used in just web applications but presently, it can be used in both, web and desktop applications.

What is Rdlc report in C#?

The RDLC stands for Report Definition Language Client side. Actually It is an extension of report file created by using Microsoft reporting technology. The SQL Server 2005 version of Report Designer is used to create these files. The ReportViewer control in client side can directly execute the RDLC reports.


2 Answers

Yes, that works, I am using the WindowsFormsHost in a wpf project to wrap the ReportViewer.

In the ViewModel I am creating the WindowsFormsHost and the ReportViewer:

WindowsFormsHost windowsFormsHost = new WindowsFormsHost(); reportViewer = new ReportViewer(); windowsFormsHost.Child = reportViewer; this.Viewer = windowsFormsHost 

and in the View I am using a ContentPresenter to display it, by binding to the Property that holds the WindowsFormsHost.

 <ContentPresenter Content="{Binding Viewer}" ... 

We're using the Business Intelligence Studio (which is an Visual Studio 2008 with templates for editing reports) for report creation. http://msdn.microsoft.com/en-us/library/ms173767.aspx

Take care,
Martin

like image 110
mdk Avatar answered Sep 24 '22 07:09

mdk


We've definitely had success just using the WindowsFormsHost. I haven't been involved in creating the RDLC files themselves, but I believe they were designed (as you say) in a WinForms project and then copied across.

Note that if you don't need local reports you can use a WPF Frame control and point it at the URL of the server-based report (it renders it like a web browser would). This works really well for us too.

like image 27
Matt Hamilton Avatar answered Sep 23 '22 07:09

Matt Hamilton