Measure string height

  • Thread starter Thread starter Dan Ardelean
  • Start date Start date
D

Dan Ardelean

Hi,
Given a string, the font and the maximum width how can I
get the height in which the text will fit?? (I have
problems because of the word wrap). The result must help
me in building a list control which adapts the dimension
of the items so the largest item (text) in the list is
fully visible on the screen and the list without
horizontal scrollbar.
Any ideas?

Thanks!
 
Dan --

I have no "elegant" solution to offer other than to use multiple calls to
MeasureString on against an off-screen bitmap changing the font size until
you hit the desired width. You can certainly be smart about the values you
try (think "binary search").

Seth Demsey
Lead Program Manager
.Net Compact Framework

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top