473,385 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How make label bold at runtime?

How do I make a label bold at runtime (i.e. in code)?

Thanks,
Ron
Jul 5 '07 #1
8 45206
Label1.Font.Bold = True
"Ronald S. Cook" <rc***@westinis.comwrote in message
news:uJ*************@TK2MSFTNGP06.phx.gbl...
How do I make a label bold at runtime (i.e. in code)?

Thanks,
Ron


Jul 5 '07 #2
It says bold is a read-only property.

"Scott M." <s-***@nospam.nospamwrote in message
news:OT**************@TK2MSFTNGP02.phx.gbl...
Label1.Font.Bold = True
"Ronald S. Cook" <rc***@westinis.comwrote in message
news:uJ*************@TK2MSFTNGP06.phx.gbl...
>How do I make a label bold at runtime (i.e. in code)?

Thanks,
Ron



Jul 5 '07 #3
Ron,

Label1.Font = New Font(Label1.Font, FontStyle.Bold)

Kerry Moorman
"Ronald S. Cook" wrote:
It says bold is a read-only property.

"Scott M." <s-***@nospam.nospamwrote in message
news:OT**************@TK2MSFTNGP02.phx.gbl...
Label1.Font.Bold = True
"Ronald S. Cook" <rc***@westinis.comwrote in message
news:uJ*************@TK2MSFTNGP06.phx.gbl...
How do I make a label bold at runtime (i.e. in code)?

Thanks,
Ron



Jul 5 '07 #4

"Ronald S. Cook" <rc***@westinis.comwrote in message
news:um**************@TK2MSFTNGP03.phx.gbl...
It says bold is a read-only property.
This may be what you're looking for possibly. It seems kind of ridiculous
that you just can't set .Bold = true.

http://www.thescarms.com/dotnet/MouseOver.aspx

Google is your friend.

Jul 5 '07 #5
"Mr. Arnold" <MR. Ar****@Arnold.comschrieb:
>It says bold is a read-only property.

This may be what you're looking for possibly. It seems kind of ridiculous
that you just can't set .Bold = true.
'Font' is only a wrapper around a Win32 'HFONT'. In Win32, font objects
cannot be altered after they have been created.

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

Jul 5 '07 #6
"Herfried K. Wagner [MVP]" <hi***************@gmx.atha scritto nel
messaggio
>This may be what you're looking for possibly. It seems kind of ridiculous
that you just can't set .Bold = true.

'Font' is only a wrapper around a Win32 'HFONT'. In Win32, font objects
cannot be altered after they have been created.
You're right, but this is not a good way.
In VB6 the Font wrapper let you change the style, name, size, ecc... and in
..Net object of this type tell me "but I need to Dispose the old one or the
fw will do it for me?".

:)
Jul 5 '07 #7
Ron -

I woudl declare the two fonts (bold and not) as private variables (ie
as "fields" in OOP terminology), and set their values in the form's
onload event handler. That will allow you to reuse the same font
objects and swap them as needed, instead of constructing a new one
each time you desire thie effect. See how much cleaner this is?

Private myFont As Font
Private myFontBold As Font

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
myFont = New Font(Label1.Font, FontStyle.Regular)
myFontBold = New Font(Label1.Font, FontStyle.Bold)
End Sub

Private Sub BoldDemo(ByVal DoIt As Boolean)
If DoIt Then
Label1.Font = myFontBold
Else
Label1.Font = myFont
End If
End Sub
Good Luck,

-Mark

Jul 5 '07 #8
"Fabio" <zn*******@virgilio.itschrieb:
>>This may be what you're looking for possibly. It seems kind of
ridiculous that you just can't set .Bold = true.

'Font' is only a wrapper around a Win32 'HFONT'. In Win32, font objects
cannot be altered after they have been created.

You're right, but this is not a good way.
In VB6 the Font wrapper let you change the style, name, size, ecc... and
in .Net object of this type tell me "but I need to Dispose the old one or
the fw will do it for me?".

Do not dispose it if it is used for more than one control. If it isn't used
any more, you can (my recommendation) safely dispose it.

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

Jul 5 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: johngilmer | last post by:
I have three radio buttons that are possible answers to a question. I have put them in a table and there is a label that goes with each radio button as its text. I would like to make some of the...
4
by: Fabrizio | last post by:
Hi I would like to create a label at runtime and show it on a web form, but once i create doesn't appear anywher How can I add the control on the web form so I can see it thank yo Fabrizio
3
by: Bart Schelkens | last post by:
Hi, i have a label on my webpage. I want to create some copys of this label at runtime, since i don't know how many labels i will be needing. How can i do this? Thx
2
by: KV | last post by:
Hi, I'm new to VB.NET and I'm trying to do something rather simple that has turned out to be a pain in the hindside. I'm developing a webpart. All I want to do is change the font of a label on...
1
by: Priya | last post by:
Hi, I'm using a repeater control. I'm binding data to repeater dynamically. I need to modify the value of a label at runtime. I modified the text in the ItemDataBound event. But while displaying...
1
by: Miguel Dias Moura | last post by:
Hello, I have a GridView in my page with a TemplateField and an Asp Label inside it. I need to access that Label in runtime and change the field to which it is binded. Can someone please...
1
by: littlebear | last post by:
I am looking to mark a location within C code with a label and determine the address of this label at runtime from X86 asm language This is for a Windows project on an Intel CPU My goal is to be...
8
by: Alexey Smirnov | last post by:
How to make bold part of the text in a Windows.Forms.Label? Thank you.
5
by: Mike | last post by:
I am trying to set the font size on a Label control. Seems like a simple item but I can't find a way to do it. I can set other properties for a Label like Borderstyle, BackColor, Fontstyle=BOLD...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.