Adding a Print Function

When you created the child form template, you included a PrintDocument control to allow for printing functionality. Some simple code will activate this feature. You can learn more about the PrintDocument control and printing in general in Chapter 23, “Creating and Using Reports.”

Coding the Print Menu Command

Open the Code window for frmChild, and then open the Click event handler for the mnuFilePrint menu item. Add the code PrintDocument1.Print() to the procedure; this will cause the PrintDocument control to begin the printing process when mnuFilePrint is clicked. Your event handler should look like the following:

 Private Sub mnuFilePrint_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles mnuFilePrint.Click ...

Get Special Edition Using Microsoft® Visual Basic® .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.