Jump to content
Xtreme .Net Talk

How to change font size in lblbox from within?


Recommended Posts

Guest shelly21
Posted

I'm having a slight issue trying to figure out how to change the font size within a lbl.box within the program.

 

The box will display some text depending on which button is pressed. And certain button produces a longer text that would not fit (well) in the label box. So when I try to use lblbox.text.font.size = 8, It doesn't work as that property is ReadOnly.

 

I could change the font colour easily, but not font size....

 

Is there another way to do this?

 

:confused:

Guest Agent
Posted

' EDIT I see your using .NET. Sorry buddy! ;)

 

It works fine for me! I used:

Option Explicit

Private Sub Form_Load()

   Label1.Font.Size = 18
   
End Sub

  • *Gurus*
Posted

Take a look at the Font class constructor. One of the methods is to specify a base font and a new size, so doing something like this:

 

Label.Font = New Font(Label.Font, 18)

 

Ought to do it for you. Something like that anyway.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Guest shelly21
Posted

That did it.

 

Strangely I had the solution in my dream last night.

 

Not the actual solution but I was dreaming about looking at the init. section to see how the label box was created in the first place.

Scary isn't it? :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...