Hi!
My customers asked for the abillity to save/load the Settings they made for the page-setup in a printpreview dialog.
Exsample: I used an GridControl to show Analysis-Data. I added a custom-Button to the embedded Navigator of the GridControl for PrintPreview:
GridControl.ShowPrintPreview
How can I save/load the usersettings made in the PrintPreview-Form (Page-Orientation, Margins) for an PreviewDialog shown for an GridControl as discribed.
Serialization - How to Save/load the settings made in a PrintPreview Dialog
Answers
Hello Dirk,
Sorry for the delay in responding. I'm sorry to inform you, but the current XtraPrinting implementation doesn't provide the ability to persist the page settings you made when printing the document. However, I think you can utilize the work-around method to manually retreive and store these settings before and after calling the ShowPreview method. But, you need to change your approach a bit - instead of using the GridControl.ShowPreview method you should use the XtraPrinting Library via the PrintableComponentLink. You should drop the PrintingSystem component onto your form, then add a PrintableComponentLink to its link collection. You can set the PrintableComponentLink.Component property to the GridControl, then use the following code to show the preview:
printableComponentLink1.CreateDocument();
printableComponentLink1.ShowPreview();
Now, you can also access the Margins settings using the printableComponentLink1.Margins property. So, you can modify the margins and page orientation before calling the CreateDocument method, then get the current settings (in case if user has modified any) , and store it within App.config or any alternative configuration for future use.
Please feel free to contact me in case of any difficulty. I'll be glad to assist you.
Thank you,
Alex.
[Updated]
This feature was implemented. See Serialization - Add methods to save/load printer settings to Registry/XML/Stream for more information.
Hello Dirk,
Thank you for the clarification. Your approach seems fine. However, I don't think I described my method in detail, sorry. You can access the printableComponentLink1.Margins after instantiating the document preview only after you call the ShowPreviewDialog method instead of the ShowPreview method, so any code next to the ShowPreviewDialog call won't be executed until the print preview window is closed. If you are calling the ShowPreview method, you need to subscribe to the form's print preview closing event. For example:
AddHandler printableComponentLink1.PrintingSystem.PreviewFormEx.FormClosed, AddressOf PreviewFormEx_FormClosed
…
Private Sub PreviewFormEx_FormClosed(ByVal sender As Object, ByVal e As FormClosedEventArgs)
' code to access the printableComponentLink1.Margins and update the settings file
End Sub
Please keep me informed of your progress.
Thank you,
Alex.
Hello Alex,
many thanks for your help! I decided for the following variation:
LoadPrintSettings …
XPrintComponentLink. CreateDocument ()
XPrintComponentLink. ShowPreviewDialog ()
SavePrintSettings …
This approach fulfils all requirements and works very well. It's good to know that I could get such competent and quick help as a DevExpress customer. Many thanks again!
Greeting from Germany
Dirk
Hello Dirk,
Thanks for your compliments - we greatly appreciate this! I am glad that my assistance was helpful.
You are welcome to contact us in case of any difficulty. We'll be glad to assist you.
Thank you,
Alex.