PC Review


Reply
Thread Tools Rate Thread

Create label with varied length run-time.

 
 
Tracey
Guest
Posts: n/a
 
      28th Aug 2003
My application requires to create labels with varied
length at runtime. But I don't know how to do that.

However, the font of string displayed in label is
different, how can I decide the length of the actual
width of the label ?

Thanks!
 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      28th Aug 2003
Hello,

"Tracey" <(E-Mail Removed)> schrieb:
> My application requires to create labels with varied
> length at runtime. But I don't know how to do that.
>
> However, the font of string displayed in label is
> different, how can I decide the length of the actual
> width of the label ?


You may want to set the label's AutoSize property to True. You can use
Graphics.MeasureString for getting the height/width of a string.

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet


 
Reply With Quote
 
Tracey
Guest
Posts: n/a
 
      28th Aug 2003
thanks, HTH.
Can you write a small example for me?

Tracey

>-----Original Message-----
>Hello,
>
>"Tracey" <(E-Mail Removed)> schrieb:
>> My application requires to create labels with varied
>> length at runtime. But I don't know how to do that.
>>
>> However, the font of string displayed in label is
>> different, how can I decide the length of the actual
>> width of the label ?

>
>You may want to set the label's AutoSize property to

True. You can use
>Graphics.MeasureString for getting the height/width of a

string.
>
>HTH,
>Herfried K. Wagner
>--
>MVP · VB Classic, VB .NET
>http://www.mvps.org/dotnet
>
>
>.
>

 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      28th Aug 2003
Hello,

"Tracey" <(E-Mail Removed)> schrieb:
> Can you write a small example for me?


\\\
Dim gr As Graphics = Me.Label1.CreateGraphics()
Dim s As Size = gr.MeasureString("Hello World!", Me.Label1.Font).ToSize()
gr.Dispose()
///

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you create a chart with varied width and length? Jamal Microsoft Excel Charting 1 20th May 2010 04:06 PM
cells of varied length extract last 3 digits PeggyT Microsoft Excel Misc 2 28th Nov 2009 07:06 PM
Subtotaling a Varied length Spreadsheet =?Utf-8?B?VGhlbyBEZWdy?= Microsoft Excel Programming 1 3rd Jul 2007 06:12 PM
Repeat Label Varied Amount of times =?Utf-8?B?QmVu?= Microsoft Access Reports 12 9th Jun 2005 04:19 AM
Excel - selecting varied length ranges for calculation Julie King Microsoft Excel Misc 2 24th Jun 2004 11:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:24 AM.