Hello!
I'm using the UltraGridPrintDocument and UltraPrintPreviewDialog to print out data from a form. It all works very well, except that the print is sent to the default printer without any possibillity to select printer. I'm looking for a solution to display an equal to the standard PrintDialog box so the user can select which printer to use, but have not been able to figure how to do it in the two controls mentioned above.
Can anybody give some input here please?
Thanks!
The UltraPrintPreviewDialog does allow the user to change the printer. Select Page Setup from the Edit menu, then click the Printer button.
Sorry, but that isn't correct... my pagesetup-dialgo does not have a "printer"-button
It's actually quite simple.
1. Add a standard PrintDialog to the form that owns the UltraPrintPreviewDialog, ensuring both dialogs have the same value for the Document property.
2. Create a handler for the Printing event of the UltraPrintPreviewDialog.
3. Add this code:
e.Cancel = printDialog.ShowDialog() == DialogResult.Cancel;
4. Enjoy. This will display the standard PrintDialog and cancel the UltraPrintPreviewDialog print if the user cancels the print dialog.
The UltraPrintPreviewDialog uses a .net PageSetup dialog when you click the Page Setup button. I believe the .net PageSetup component will just show the OS' page setup dialog which may have a printer option but that is not something that you can rely on.
I can't find that I have done anything special, but when I select Page Setup from the File menu of the UltraPrintPreviewDialog, I get a window that allows me to change paper source and size, orientation and margins and has a Printer... button to the right of OK and Cancel. This does look like a standard Windows dialog instead of an Infragistics one.
I can even use the following line of code to determine which printer the user has selected:
SelectedPrinter = this.ultraGridPrintDocument1.PrinterSettings.PrinterName;
There is no button in the default UltraPrintPreviewDialog to show or change the printer. You would probably have to access the ToolbarsManager property (which is public), add a ButtonTool to it (maybe to the File menu – File is actually the key of the PopupMenuTool), handle its ToolClick and show a PrintDialog whose Document is set to the printdocument you are previewing and if the printer is changed call the public InvalidatePreview method so the preview can be regenerated.
I am curious about this also. Can someone from Infragistics take some time to address this?