By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,693 Members | 1,560 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,693 IT Pros & Developers. It's quick & easy.

how to toggle label.Text Bold/Regular?

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Rich" <Ri**@discussions.microsoft.com> schrieb:
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)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

P: n/a
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.

"Herfried K. Wagner [MVP]" wrote:
"Rich" <Ri**@discussions.microsoft.com> schrieb:
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)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

P: n/a
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))

Rich wrote:
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

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.