Hi Leetech,
If you are wanting to print the form, this is the method I use. For the form, Met3Grid, the code for the Print Form Button (Command4) is as shown below. Most of this code simply turns off stuff not to be printed and then after printing, turning the stuff back on.
Private Sub Command4_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command4.Click
Dim J As Integer
Command1.Visible = False
Command2.Visible = False
Command3.Visible = False
Command4.Visible = False
Command5.Visible = False
Command6.Visible = False
Label5.Visible = False
Label6.Visible = False
Label7.Visible = False
Label8.Visible = False
Met3Grid.DefInstance.BackColor = System.Drawing.ColorTranslator.FromOle(&HFFFFFF)
'We make the form look pretty before its picture
Application.DoEvents()
Me.Refresh()
Application.DoEvents()
'Get a Graphics Object from the form
Dim FormG As Graphics = Me.CreateGraphics
'Create a bitmap from that graphics
Dim i As New Bitmap(Me.Width, Me.Height, FormG)
'Create a Graphics object in memory from that bitmap
Dim memG As Graphics = Graphics.FromImage(i)
'get the IntPtr's of the graphics
Dim HDC1 As IntPtr = FormG.GetHdc
Dim HDC2 As IntPtr = memG.GetHdc
'get the picture
BitBlt(HDC2, 0, 0, Me.ClientRectangle.Width, Me.ClientRectangle.Height, HDC1, 0, 0, 13369376)
'Clone the bitmap so we can dispose this one
Me.Print_Image = i.Clone()
'Clean Up
FormG.ReleaseHdc(HDC1)
memG.ReleaseHdc(HDC2)
FormG.Dispose()
memG.Dispose()
i.Dispose()
'Show the PrintDialog
PrintDialog1 = New PrintDialog
PrintDialog1.Document = PrintDocument1
Dim r As DialogResult = PrintDialog1.ShowDialog
If r = DialogResult.OK Then
'Print the document
PrintDocument1.Print()
End If
Met3Grid.DefInstance.BackColor = System.Drawing.ColorTranslator.FromOle(&H8000000F)
Command1.Visible = True
Command2.Visible = True
Command3.Visible = True
Command4.Visible = True
Command5.Visible = True
Command6.Visible = True
Label5.Visible = True
Label6.Visible = True
Label7.Visible = True
Label8.Visible = True
End Sub