Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Which event used to preview print document instead of print ?
I need to preview data not print

so what event used for preview or load printdocument without print


What I have tried:

under button
private void button1_Click(object sender, EventArgs e)
        {
          
            PrintDocument document = new PrintDocument();
            PrintController printController = new StandardPrintController();
            document.PrintController = printController;
       
// what event used here for preview data not print


    

            PrintPreviewDialog ppDialog = new PrintPreviewDialog();
        
            ((ToolStripButton)((ToolStrip)ppDialog.Controls[1]).Items[0]).Enabled = false;
            ppDialog.Document = document;
           
            ppDialog.Show();

        }

private void printDocument_PrintPage(object sender, PrintPageEventArgs e)  
        {  
some code display grid  
        }  
Posted
Updated 2-Feb-19 19:28pm

1 solution

The whole idea of a PrintDocument is that the PrintPage method is used to print the data regardless of the destination.

The difference is that for a PrintPreview you do this:
C#
PrintPreviewDialog ppd = new PrintPreviewDialog();
ppd.Document = myPrintDocument;
ppdialog.Show();
And for a "real" print you do this:
C#
myPrintDocument.Print();
 
Share this answer
 
Comments
Maciej Los 3-Feb-19 15:54pm    
Ho, no! It can't be so easy.
:laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900