D
Dilip
Howdy Folks
I have a display where the Graphics.DrawString function is called to
display something. Since the text seems to be larger than its
bounding rectangle, the call basically splits the string into multiple
lines.
Is there a way to find out into how many lines the string was split?
I am asking because this string is being displayed inside an owner
drawn list view. I need to make the height of the row big enough to
accommodate this multi-line string. But I can't seem to reliably
determine how to do that. I thought:
Graphics graphicsObject = ...;
Font someFont = ...;
StringFormat sf = ...;
Rectangle rect = ...;
string s = "This is some string";
SizeF measuredSize = graphicsObject.MeasureString(s, someFont, new
Point(2, 2), sf);
graphicsObject.DrawString(s, someFont, someBrush, rect, sf);
int lines = (int)(measuredSize.Width / rect.Width) + 1; // add 1 to be
on the safe side
The above line doesn't seem to give the correct answer.
Any ideas?
I have a display where the Graphics.DrawString function is called to
display something. Since the text seems to be larger than its
bounding rectangle, the call basically splits the string into multiple
lines.
Is there a way to find out into how many lines the string was split?
I am asking because this string is being displayed inside an owner
drawn list view. I need to make the height of the row big enough to
accommodate this multi-line string. But I can't seem to reliably
determine how to do that. I thought:
Graphics graphicsObject = ...;
Font someFont = ...;
StringFormat sf = ...;
Rectangle rect = ...;
string s = "This is some string";
SizeF measuredSize = graphicsObject.MeasureString(s, someFont, new
Point(2, 2), sf);
graphicsObject.DrawString(s, someFont, someBrush, rect, sf);
int lines = (int)(measuredSize.Width / rect.Width) + 1; // add 1 to be
on the safe side
The above line doesn't seem to give the correct answer.
Any ideas?