I have the following sub that handles printing of a document:
VB Code:
Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage Dim boldfont As New Font("Arial", 16, FontStyle.Bold) Dim smallfont As New Font("Arial", 10, FontStyle.Regular) Dim regularfont As New Font("Arial", 16, FontStyle.Regular) Dim ulboldfont As New Font("Arial", 16, FontStyle.Bold Or FontStyle.Underline) Dim footerfont As New Font("Arial", 8, FontStyle.Regular) With e.Graphics ' Printing code End With e.HasMorePages = False boldfont.Dispose() smallfont.Dispose() regularfont.Dispose() ulboldfont.Dispose() footerfont.Dispose() e.Graphics.Dispose() End Sub
Is it good practice to dispose of the fonts and the graphics object at the end, or is this not necessary?
Thanks.





Reply With Quote