Reset Bold Read Only Property (1 Viewer)

grnzbra

Registered User.
Local time
Today, 16:49
Joined
Dec 5, 2001
Messages
376
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

Registered User.
Local time
Today, 18:49
Joined
Dec 21, 2004
Messages
342
just use the font property.
Code:
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

Registered User.
Local time
Today, 16:49
Joined
Dec 5, 2001
Messages
376
Thank you.
 

Users who are viewing this thread

Top Bottom