Click here to Skip to main content
15,888,062 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I am using crystal report in a WPF application designed in visual studio 2010. I have used two report viewers to display crystal report;

1 : Microsoft.ReportViewer.WinForms

Code :

<Window x:Class="HelloWorld.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:rv="clr- namespace:Microsoft.Reporting.WinForms;assembly=Microsoft.ReportViewer.WinForms"
        Title="WFReportViewer" Height="800" Width="900">
    <Grid>
        <WindowsFormsHost Height="700" Name="windowsFormsHost1" Width="800">
            <rv:ReportViewer x:Name="_reportViewer" />
        </WindowsFormsHost>
    </Grid>
    </Window>


Output :

[Post I run the above code, below is the output][1]

[1]: https://i.stack.imgur.com/MHRSu.png

[When I click on page setup, I get this option ][2]

[2]: https://i.stack.imgur.com/sVgby.png

So, I can do page setup, view the changes, and can print the report then.

2: SAP CrystalReportsViewer

Code :

<Window x:Class="HelloWorld.CrystalReportWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:my="clr-namespace:SAPBusinessObjects.WPF.Viewer;assembly=SAPBusinessObjects.WPF.Viewer"
            Title="CrystalReportWindow" Height="800" Width="900" Loaded="Window_Loaded">
        <Grid Name="grid1">
            <my:CrystalReportsViewer HorizontalAlignment="Left" Name="crystalRptVwr1" VerticalAlignment="Top" Height="700" Width="850" ShowOpenFileButton="False" ShowPrintButton="True" ShowExportButton="True" SnapsToDevicePixels="False" UseLayoutRounding="False" />
        </Grid>
    </Window>


Output :

[When I run this code, I get this output][3]

[3]: https://i.stack.imgur.com/dJJG3.png

Now, an only print option is available here. there is no layout option or page setup option in crystal report viewer. I need to add them so that after we run crystal report, the user should be able to change page setup and check it's preview.

I have searched on the internet a lot, but not able to find any solution. Can anyone please advice and help me on this?

Thanks in advance.

What I have tried:

I have tried creating my own print option and custom window to set page setup, but that is not covering all scenarios. Also, it is getting my application slow. I searched on the internet a lot but didn't find any solution.
Posted
Updated 14-Mar-18 0:42am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900