Print the form
-
Hi to All, i want to print out the perticuler form. plz tell me about code of print the perticuler form thru printer.... thanking you...
Impact Pro
Hello, You may take a snapshot of Form using PrintToBitmap function of Form. Following is a code snippet to do so- bmp = New Bitmap(Me.ClientRectangle.Width, Me.ClientRectangle.Height) Me.DrawToBitmap(bmp, New Rectangle(Me.ClientRectangle.X, Me.ClientRectangle.Y, Me.ClientRectangle.Width, Me.ClientRectangle.Height)) Me.PictureBox2.Image = bmp If you want to print this data then you will need to add one PrintDocument object, like this- Dim WithEvents pdoc As New System.Drawing.Printing.PrintDocument Add code in PrintPage Event of PrintDocument object something like – e.Graphics.DrawImage(bmp, Me.ClientRectangle.X, Me.ClientRectangle.Y) Then you may get it printed by simply using a line of code- pdoc.Print() This would print the picture of the form. I hope this helps:). -Dave.
Dave Traister, ComponentOne LLC. www.componentone.com
-
Hello, You may take a snapshot of Form using PrintToBitmap function of Form. Following is a code snippet to do so- bmp = New Bitmap(Me.ClientRectangle.Width, Me.ClientRectangle.Height) Me.DrawToBitmap(bmp, New Rectangle(Me.ClientRectangle.X, Me.ClientRectangle.Y, Me.ClientRectangle.Width, Me.ClientRectangle.Height)) Me.PictureBox2.Image = bmp If you want to print this data then you will need to add one PrintDocument object, like this- Dim WithEvents pdoc As New System.Drawing.Printing.PrintDocument Add code in PrintPage Event of PrintDocument object something like – e.Graphics.DrawImage(bmp, Me.ClientRectangle.X, Me.ClientRectangle.Y) Then you may get it printed by simply using a line of code- pdoc.Print() This would print the picture of the form. I hope this helps:). -Dave.
Dave Traister, ComponentOne LLC. www.componentone.com