469,929 Members | 1,597 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,929 developers. It's quick & easy.

How do you programatically set Label Font size

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 etc.
I'm using VB.NET 2003.

Thanks for any feedback

Jun 27 '08 #1
5 44313

"Mike" <mi*******@hotmail.comkirjoitti viestissä
news:Sp******************************@pghconnect.c om...
>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 etc.
I'm using VB.NET 2003.
You have to create a new instance of font. If you need just to change the
size, this

Label1.Font = New Font(Label1.Font.FontFamily,20)

might be the easiest way. If you need more options, you can use another
constructor to create for example bolded text.

-Teemu

Jun 27 '08 #2
On May 11, 6:21*pm, "Mike" <mikea3...@hotmail.comwrote:
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 etc.
I'm using VB.NET 2003.

Thanks for any feedback
Hi,
Using VB 2005,
Could you find "font" on label's property window then you should be
able to tweak front types / sizes.

Or if you want to set font of label on runtime, you can use for
example;

Dim myfont As New Font("Sans Serif", 26, FontStyle.Regular)
label1.font = myfont

... where argument "26" is your font size that you can set to what you
desire.

Thanks,

Onur Güzel
Jun 27 '08 #3
"Mike" <mi*******@hotmail.comschrieb
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 etc.
I'm using VB.NET 2003.

Thanks for any feedback

Assign a Font object to the Font property.
Armin
Jun 27 '08 #4

Ozur,

Dim myfont As New Font("Sans Serif", 26, FontStyle.Regular)
label1.font = myfont

this is the same in 2003

Cor
Jun 27 '08 #5
On Sun, 11 May 2008 09:21:26 -0700 (PDT), kimiraikkonen
<ki*************@gmail.comwrote:
>On May 11, 6:21*pm, "Mike" <mikea3...@hotmail.comwrote:
>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 etc.
I'm using VB.NET 2003.

Thanks for any feedback

Hi,
Using VB 2005,
Could you find "font" on label's property window then you should be
able to tweak front types / sizes.

Or if you want to set font of label on runtime, you can use for
example;

Dim myfont As New Font("Sans Serif", 26, FontStyle.Regular)
label1.font = myfont

... where argument "26" is your font size that you can set to what you
desire.

Thanks,

Onur Güzel
I would prefer:
label1.Font = New Fontlabel1.Font.FontFamily, 26, label1.Font.Style)

That way everything is the same except the size even if the font
family or style change later.
Jun 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Stuart Norris | last post: by
11 posts views Thread by Peter Larsen [] | last post: by
6 posts views Thread by Miro | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.