View Full Version : Reset Bold Read Only Property


grnzbra
11-14-2006, 05:54 AM
I was playing with vb2005 express last night and doing an exercise which changed the text on a button controled by the MouseEnter and MouseExit events. This worked fine. I then decided to try it with a lable to set the font to bold when the mouse entered the label. I got an error saying that it couldn't be done because Bold was read only and that I should change the read only property. However, in my search for how to change this, I came up empty handed.

How would one go about changing the Font.Bold property from read only?

skea
11-15-2006, 03:34 AM
just use the font property.

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
If Not Me.Label1.Font.Bold Then
Me.Label1.Font = New Font(Me.Label1.Font, FontStyle.Bold)
ElseIf Me.Label1.Font.Bold Then
Me.Label1.Font = New Font(Me.Label1.Font, FontStyle.Regular)
End If
End Sub

grnzbra
11-15-2006, 10:39 AM
Thank you.