Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
Adding a ButtonTool to PrintPreviewDialog
posted

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

TIA
Jan C. Potthoff

Parents
No Data
Reply
  • 835
    posted

    Hi bgfe, I have an idea that you can use.  You can catch the Printing event of the PrintPreviewDialog and when you catch the event you can cancel it and show your own print dialog window. e.g.

    private void PrintPreviewDialog_Printing(object sender, PrintingEventArgs e) {

    // cancel the printing for PrintPreviewDialog

    // the printdialog will handle the printing

    e.Cancel = true;this.ShowGridPrintDialog(this);

    }

     

    /// <summary>

    /// Shows a print dialog to print the report.

    /// </summary>

    /// <param name="owner">IWin32Window owner.</param>

    public void ShowGridPrintDialog(IWin32Window owner)

    {

    // set your GridPrintDocument here

    this.GridPrintDocument.Grid = this.Grid;

    PrintDialog dlg = new PrintDialog();

    dlg.AllowSelection = true;

    dlg.AllowSomePages = true;

    dlg.Document = this.GridPrintDocument;

    if (dlg.ShowDialog(owner) == DialogResult.OK)

    {

    this.GridPrintDocument.Print();

    }

    }

     

Children
No Data