Question

what is equivalent WindowsFormsHost in C# winform? i wrote program in C# winform. in my user control(instead of form), i put reporting. when user clicked btnReporting, rptfile is shown. this is my code in wpf. i don't equivalent WindowsFormsHost in C# winform?

 CrystalReportViewer rptViewer = new CrystalReportViewer();
            rptViewer.DisplayStatusBar = false;

            WindowsFormsHost host = new WindowsFormsHost();
            rptViewer.ReportSource = rep;
            host.Child = rptViewer;
            ReportRpt PageRpt = new ReportRpt();

            PageRpt.GrdReport.Children.Add(host);
            NavigationService navService = NavigationService.GetNavigationService(this);
            navService.Navigate(PageRpt);
Was it helpful?

Solution

For showing crystal report on Winform, you may add the Crystal Viewer from the toolbox on the form and set the crystal report against it.

Please see: Displaying Crystal Reports using WinForms and C#

but if you want to host a WPF control in Winform then you can use ElementHost

A Windows Forms control that can be used to host a Windows Presentation Foundation (WPF) element.

OTHER TIPS

you dont need a windows forms host in winforms - thats just for backwards compatibility in WPF just add the reference to crytal reports and place the control on your form

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top