Using The Built-In Print Dialog Box

Sending a file to the printer in most cases only requires a single line of code. The TextControl.Print method will open a dialog box to let the user select a printer and all required options.

This code sample will open a print dialog box, and, if the user clicks OK, print the document:

[C#]
private void mnuFile_Print_WithBuiltInDialog_Click(object sender, System.EventArgs e)
{
    textControl1.Print("My Print Job");
}
[Visual Basic]
Private Sub mnuFile_Print_WithBuiltInDialog_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles mnuFile_Print_WithBuiltInDialog.Click
    TextControl1.Print("My Print Job")
End Sub
[Delphi]
procedure Form1.mnuFile_Print_WithBuiltInDialog_Click(sender: System.Object;
    e: System.EventArgs);
begin
    TextControl1.Print('My Print Job');
end;

Next >>