Re: How do you programatically set Label Font size

K

kimiraikkonen

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
 
C

Cor Ligthert[MVP]

Ozur,

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

this is the same in 2003

Cor
 
J

Jack Jackson

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.
 
F

Frank Bearss

I use...

mycontrol.font.size = New System.Web.UI.WebControls.FontUnit(10)


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
On Sunday, May 11, 2008 11:54 AM Armin Zingler wrote:
Assign a Font object to the Font property.


Armin
 

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