Category / Section
How to display the Editcontrol content in MS Print Preview control?
1 min read
In EditControl, the PrintDocument property is used to display the contents of EditControl and it can be assigned to MS PrintPreviewControl by using its property named “Document”. And this Document can be displayed by using the function named “ShowDialog”. The following code example is to demonstrate the same.
C#
//Object creation. Form PrintForm = new Form(); //Add print preview controls to Form. PrintForm.Controls.Add(this.printPreviewControl1); //Assign EditControl print document to PrintPreview control. this.printPreviewControl1.Document = this.Editcontrol.PrintDocument; //To show print dialog. PrintForm.ShowDialog(); //To show the Edit control print preview dialog. this.Editcontrol.PrintPreview();
VB
'Object creation. Private PrintForm As New Form() 'Add print preview controls to Form. PrintForm.Controls.Add(Me.printPreviewControl1) 'Assign EditControl print document to PrintPreview control. Me.printPreviewControl1.Document = Me.Editcontrol.PrintDocument 'To show print dialog. PrintForm.ShowDialog() 'To show the Edit control print preview dialog. Me.Editcontrol.PrintPreview()
Screenshot: