Groups | Blog | Home
all groups > dotnet compact framework > july 2005 >

dotnet compact framework : needed lines for Text-expression, word wrapping


Alex Yakhnin [MVP]
7/7/2005 9:43:06 AM
Take a look at this:

http://blog.opennetcf.org/ayakhnin/PermaLink.aspx?guid=c43a1365-af59-4d83-81ff-57e0c4a05805

--
Alex Yakhnin, .NET CF MVP
www.intelliprog.com | www.opennetcf.org


[quoted text, click to view]
c_xyTopa
7/7/2005 11:21:35 AM
hi all,

a have a Label-Text with x-Words. I need to count how many lines are
needed in order to set the Label.Height (Label.Width maxLabelWidth is
constant).

I count the words, count their size with blanks between them

SizeF szF = g.MeasureString(currentWord, this.label1.Font);
sum += sz.ToSize().Width;

in the end I count lines needed

neededLinesCounter = sum / maxLabelWidth;
if (sum % maxLabelWidth > 0)
neededLinesCounter++;



the problem:
if the size of all words is 500 and maxLabelWidth = 160 I get 4 lines
and the whole expression fixes fine.

if the size of all words is 500 and maxLabelWidth = 120 I get 5 lines
and the whole expression does not fix.

I suppose it's while the words wrapping is not available.
How could I solve the problem?

thanx

AddThis Social Bookmark Button