Label; Lines of words

georgepatotk

Contributor
Joined
Mar 1, 2004
Messages
432
Location
Malaysia
i need help in determine the 'lines of words' in Label.

I have a string in a Label, and the string will change dynamically.

I want to catch the number of lines for the words on everytime it changed.

For example:

I assign "Hello, world!"; the lines of words might be 1
If I assign with "Hello, world! I am the one who is in doubt. Please help me!"; then lines of words might goes to 3 because the wordwrap.

Please let me know on how to solve this problem.

Thank you in advance.
 
Hi, George

Strange, System.Windows.Forms.Label class doesn't have a "wordwrap" property.

Perhaps you might check Height property of the label in order to find out how many lines it has...

Marcelo
 
It is pretty straightforward when you use the Graphics.MeasureString method, the online help is sufficient to figure out how to use it. There are several ways to use it but it will as it says
'Measures the size of the string and determines the number of characters fitted and lines filled, using the string, the font object, the maximum layout size, and the string format. '
 
Back
Top