Issues With Printing GridView

1 Answer 20 Views
SpreadProcessing
Neil N
Top achievements
Rank 2
Iron
Iron
Veteran
Neil N asked on 21 Apr 2025, 09:48 PM

We need to print a GridView and are implementing the code found in "GridView | Print and Print Preview" example in the WPF Desktop Examples 2024 Q4  app but are encountering two issues also present in the Telerik-provided example.

1) Changes made in Print Preview are not carried over when the Print button is pressed.  For example, if you change to Landscape/Legal in Print Preview, this will revert back to Portrait/Letter when Print is clicked.

2) Clicking Print on the Print Preview window shoves the Print Preview window to the background and if Cancel is clicked on the Print window, the user has to Alt-Tab through windows to find the Print Preview window to close it.

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 24 Apr 2025, 12:35 PM

Hello Neil,

The observed behavior regarding the first part of your message is expected. Generally, the "GridView | Print and Print Preview" example contains two buttons that showcase the two printing options of the RadSpreadsheet control. The Print button executes the Print method of the RadSpreadsheet control, whereas the Print Preview button utilizes the Print Preview functionality, which allows you to customize the sheets prior to exporting them via the Print button in the top-left corner of the dialog (not the one above the Print Preview button). 

About the second question, the created RadWindow element that hosts the PrintPreviewControl in the mentioned example does not have its IsTopMost property set. To change this, navigate to the CreatePreviewWindow method in the PrintAndPrintPreviewExtensions class and set the IsTopMost property of the created RadWindow to True. This way, the window will stay on top of the screen.

If the top-most approach is not desired, you could utilize the RadWindowInteropHelper.SetShowInTaskBar method, to display the RadWindow in the taskbar. This way, the user can view it in the taskbar and close it, instead of using the ALT + Tab key combination to navigate to it.

The following code snippet showcases the implementation for both of these suggestions regarding the second question:

private static RadWindow CreatePreviewWindow(FrameworkElement previewControl)
{
    Grid grid = new Grid();
    grid.RowDefinitions.Add(new RowDefinition());
    grid.Children.Add(previewControl);

    Grid.SetRow(previewControl, 0);

    RadWindow window = new RadWindow()
    {
        //Set IsTopmost
        //IsTopmost = true,
        Content = grid,
        Width = 900,
        Height = 670,
        Header = "Print Preview",
        WindowStartupLocation = WindowStartupLocation.CenterScreen
    };

    //Utilize the RadWindowInteropHelper.SetShowInTaskbar method
    //RadWindowInteropHelper.SetShowInTaskbar(window, true);

    return window;
}

With this being said, I hope the provided information will be of help to you.

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Neil N
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 24 Apr 2025, 12:46 PM

Hi Stenly,

I am clicking the Print button in the top-left corner of the dialog. The changed settings are not carried over.

 

 

 

Stenly
Telerik team
commented on 29 Apr 2025, 12:24 PM

Hello Neil,

I tested the example with these steps, however, I was unable to reproduce this behavior. I tested it on a machine with a Windows 10 OS.

With this in mind, I also tested this on a Windows 11 machine and I was able to reproduce this behavior. I will need a bit more time to further review this scenario.


Neil N
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 29 Apr 2025, 01:00 PM

Thanks, Stenly. I look forward to hearing your findings.
Stenly
Telerik team
commented on 02 May 2025, 12:41 PM

Hello Neil,

I further tested this scenario on a Windows 11 machine, and it seems that this is an issue stemming from the .NET framework.

More specifically, internally, we open a new native WPF PrintDialog when clicking the Print button in the Print Preview dialog. The configured customizations in the Print Preview dialog are examined, and the PrintTicket property of the WPF PrintDialog is modified based on them. This produces the expected result when working with the Windows 10 OS version, however, there seems to be an issue when this logic is executed on the Windows 11 OS version.

This behavior is discussed in the following GitHub issue, which is still not resolved:

Print Dialog Settings in Windows 11 22H2 Not Honored · Issue #8355 · dotnet/wpf

With this being said, I hope the provided information will be of help to you. I also looked for a possible workaround, however, I was unable to come up with one. 

Tags
SpreadProcessing
Asked by
Neil N
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Stenly
Telerik team
Share this question
or