2

I would like to count the number of lines a particular string will occupy when wrapped in a container with a fixed width, and using a given font...

My original problem was getting the height of a row in excel with wrapped text. I've given up on a straightforward solution so I would like to use an algorithm for determining the number of lines occupied (and hence the height of the row).

I realize I can develop my own algorithm making use of Graphics.MeasureString, but I was wondering if there is an already developed clean solution that won't make me go through this mess.

Community
  • 1
  • 1
Karim
  • 247
  • 4
  • 11
  • 1
    I doubt it. But since `Graphics.MeasureString` lets you pass in the width of the container: _To accommodate the entire string, the returned Height component is adjusted to a value that allows displaying the string with character wrap_ (MSDN) it won't necessarily be such a mess..if you can live with character wrap, of course! – TaW Aug 13 '14 at 16:55

0 Answers0