We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How do I add Print/Print Preview to my Essential Diagram application?


The following code sample shows how you can add Print and Print/Preview support to your Essential Diagram application using the CreatePrintDocument Method:


//Set up Print private void Print() {  System.Drawing.Printing.PrintDocument printDoc = this.diagram1.CreatePrintDocument();  PrintDialog printDlg = new PrintDialog();  printDlg.Document = printDoc;  if (printDlg.ShowDialog(this) == DialogResult.OK)  {   printDoc.Print();  } }

//Set up Print Preview private void PrintPreview() {  System.Drawing.Printing.PrintDocument printDoc = this.diagram1.CreatePrintDocument();  PrintPreviewDialog printPreviewDlg = new PrintPreviewDialog();  printPreviewDlg.Document = printDoc;  printPreviewDlg.ShowDialog(this); }

//Print Preview Button private void printpreviewbutton_Click(object sender, System.EventArgs e) {  this.PrintPreview(); }

//Print Button private void printtbutton_Click(object sender, System.EventArgs e) {  this.Print(); }

[VB.NET] 'Set up Print Private  Sub Print()  Dim printDoc As System.Drawing.Printing.PrintDocument =  Me.diagram1.CreatePrintDocument()  Dim printDlg As PrintDialog =  New PrintDialog()  printDlg.Document = printDoc  If printDlg.ShowDialog(Me) = DialogResult.OK Then   printDoc.Print()  End If End Sub   'Set up Print Preview Private  Sub PrintPreview()  Dim printDoc As System.Drawing.Printing.PrintDocument =  Me.diagram1.CreatePrintDocument()  Dim printPreviewDlg As PrintPreviewDialog =  New PrintPreviewDialog()  printPreviewDlg.Document = printDoc  printPreviewDlg.ShowDialog(Me) End Sub   'Print Preview Button Private  Sub printpreviewbutton_Click(ByVal sender As Object, ByVal e As System.EventArgs)  Me.PrintPreview() End Sub   'Print Button Private  Sub printtbutton_Click(ByVal sender As Object, ByVal e As System.EventArgs)  Me.Print() End Sub

Article ID: Published Date: Last Revised Date: Platform: Control:
162 04/30/2011 07/10/2014 Windows Forms Diagram
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.