How to print Dialog
Create a new Windows application Form Here the name of the application is (Print Dialog )
Set the Text property of form1 as Print Dialog
Drag & Drop One Button Control, one PrinterDialog Control.and PrintDocument object from the Toolbox
Set the Name property of the button as BtnPrint the Text property as Print
Now, after setting the control property, Double Click on the print button and add the following code
Private Sub BtnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnPrint.Click
PrintDialog1.Document = PrintDocument1
PrintDialog1.PrinterSettings = PrintDocument1.PrinterSettings
PrintDialog1.AllowSomePages = True
If PrintDialog1.ShowDialog =Windows.Forms.DialogResult.OK Then
PrintDocument1.PrinterSettings = _PrintDocument1.PrinterSettings
PrintDocument1.Print()
End If
End Sub
Private Sub docprinting(ByVal sender As Object, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
Handles PrintDocument1.PrintPage
Dim str As String = "The quick brown dog Jumped over the lazy Fox."
Dim prnfont As New System.Drawing.Font _
("Arialr", 25, System.Drawing.FontStyle.Regular)
e.Graphics.DrawString(str, prnfont, System.Drawing.Brushes.Black, 20, 7)
End Sub
End Class
Press F5 key from the keyboad to run the applicatin
Click the print Button to print the Document