Hi,
I'm using a PrintPreviewDialog to display a grid's content before printing.
The user should be able to limit the printed pages. I want to do it with these options:
myPrintDoc.DefaultPageSettings.PrinterSettings.ToPage myPrintDoc.DefaultPageSettings.PrinterSettings.FromPage
My first choice was to open a form during the myUltraPreviewDiaglog.Printing event where the user could specify these values.
But now I'd like to group this function with other functions and make them accessible while the user is looking at the preview.
To sum it up:Is it possible to add an menu item or button tool to the toolbar in the print preview dialog to open a new form where the user can define the layout and the ToPage and FromPage settings?
I'm using NetAdvantage for Windows Forms 2006 Vol 3
TIAJan C. Potthoff
Good question. I too would like to know if this is possible.
ET
The UltraToolbarsManager of the UltraPrintPreviewDialog is a public property but its only available in code. So you could use code to create a button tool, add it to the root tools collection. Then create an instance of that tool in the File menu (the key of the menu tool is "File"). Then in the ToolClick for that tool, you can show your dialog and if the preview needs to be updated, call the public InvalidatePreview method (e.g. if you change the From/To page). It is important to note that it is up to a print document to decide to support selectively printing pages. In the case of the UltraGrid, it does support the FromPage/ToPage so you can do something like what you describe. Other print documents like the ultrascheduleprintdocument do not support this so a feature suggestion would have to be submitted for that.
e.g.
ButtonTool tool = new ButtonTool("PrintSetup"); tool.SharedProps.Caption = "Print Setup..."; this.ultraPrintPreviewDialog1.ToolbarsManager.Tools.Add(tool); PopupMenuTool menu = (PopupMenuTool)this.ultraPrintPreviewDialog1.ToolbarsManager.Tools["File"]; menu.Tools.InsertTool(2, "PrintSetup"); tool.ToolClick += new ToolClickEventHandler(OnPrintSetupClick); }
void OnPrintSetupClick(object sender, ToolClickEventArgs e) { if (this.printDialog1.ShowDialog(this.ultraPrintPreviewDialog1) == DialogResult.OK) this.ultraPrintPreviewDialog1.InvalidatePreview(); }