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" wrote:
> 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
>
>
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