how to toggle label.Text Bold/Regular?

G

Guest

Could someone share how to toggle the font property of a label from regular
to bold and back to regular? I have tried label.Font.Bold = True but get the
error message that this property is ReadOnly. Label.Font.Style =
FontStyle.Bold --> ReadOnly error again. Any Suggestions appreciated.

Thanks
 
H

Herfried K. Wagner [MVP]

Rich said:
Could someone share how to toggle the font property of a label from
regular
to bold and back to regular? I have tried label.Font.Bold = True but get
the
error message that this property is ReadOnly. Label.Font.Style =
FontStyle.Bold --> ReadOnly error again. Any Suggestions appreciated.

\\\

' Removing bold style.
Me.Label1.Font = _
New Font(Me.Button1.Font, Me.Label1.Font.Style And Not FontStyle.Bold)

' Adding bold style.
Me.Label1.Font = _
New Font(Me.Button1.Font, Me.Label1.Font.Style Or FontStyle.Bold)
///
 
G

Guest

Thanks very much. This is consistent with what I came up with (finally)

Dim font1 As New Font("Aria", 10, FontStyle.Bold)
Label.Font = font1

Your methods seems more dynamic/efficient since I don't have to Dim each time.

Thanks again.
 
S

Supra

try this i used to this in mirc chat .
Dim IsBold As Boolean = ((Label1.Font.Bold And FontStyle.Bold) =
FontStyle.Bold)
Label1.Font = New Font(Label1.Font.Bold,
DirectCast(IIf(IsBold, Label1.Font.Bold And Not FontStyle.Bold,
Label1.Font.Bold Or FontStyle.Bold), FontStyle))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top