Font - Dispose question.

  • Thread starter Thread starter Rob Panosh
  • Start date Start date
R

Rob Panosh

Hello,

If I create a font on my inherited form (sample code below) do I have
to "Dispose" this font.

Thanks,
Rob

Class MyTest
Inherits System.Windows.Forms.Form

Private _font as As System.Drawing.Font

Public Sub New()

Me.InitializeComponent()

Me._font = New System.Drawing.Font(Me.Font.FontFamily, 10,
Drawing.FontStyle.Bold)

End Sub

End Class
 
Rob said:
Hello,

If I create a font on my inherited form (sample code below) do I have
to "Dispose" this font.

Thanks,
Rob

Class MyTest
Inherits System.Windows.Forms.Form

Private _font as As System.Drawing.Font

Public Sub New()

Me.InitializeComponent()

Me._font = New System.Drawing.Font(Me.Font.FontFamily, 10,
Drawing.FontStyle.Bold)

End Sub

End Class

No. As you assign the font to a control, the control will take care of that.
 
Goran,

What if I'm using the font on a tree node? That that make any
difference.

Sample:
-----------
Dim newNode as System.Window.Forms.TreeNode =
me.TreeView1.Nodes.Add("myTest")
newNode.Font = me._font


Thanks,
Rob
 
Rob said:
Goran,

What if I'm using the font on a tree node? That that make any
difference.

Sample:
-----------
Dim newNode as System.Window.Forms.TreeNode =
me.TreeView1.Nodes.Add("myTest")
newNode.Font = me._font


Thanks,
Rob

The TreeNode class doesn't have a Font property.
 
Sorry I had a typo. The Node does have a font property "NodeFont".

newNode.NodeFont = me._font

Rob
 
Back
Top