@@ -31,7 +31,10 @@ Public Class Form1
31
31
'/ </summary>
32
32
Protected Overloads Overrides Sub Dispose( ByVal disposing As Boolean )
33
33
If disposing Then
34
- If (components IsNot Nothing ) Then
34
+ If fnt IsNot Nothing Then
35
+ fnt.Dispose()
36
+ End If
37
+ If components IsNot Nothing Then
35
38
components.Dispose()
36
39
End If
37
40
End If
@@ -65,6 +68,7 @@ Public Class Form1
65
68
' This example assumes that the Form_Load event handler method is connected
66
69
' to the Load event of the form.
67
70
Private pictureBox1 As New PictureBox()
71
+ Private fnt as New Font( "Arial" , 10 )
68
72
69
73
Private Sub Form1_Load( ByVal sender As Object , ByVal e As System.EventArgs) Handles MyBase .Load
70
74
' Dock the PictureBox to the form and set its background to white.
@@ -84,7 +88,7 @@ Public Class Form1
84
88
85
89
' Draw a string on the PictureBox.
86
90
g.DrawString( "This is a diagonal line drawn on the control" , _
87
- New Font( "Arial" , 10 ) , Brushes.Red, New PointF( 30 . 0 F, 30 . 0 F))
91
+ fnt , Brushes.Red, New PointF( 30.0F , 30.0F ))
88
92
' Draw a line in the PictureBox.
89
93
g.DrawLine(System.Drawing.Pens.Red, pictureBox1.Left, _
90
94
pictureBox1.Top, pictureBox1.Right, pictureBox1.Bottom)
0 commit comments