1 Attachment(s)
[RESOLVED] Measure the height of a string with a FIXED max width
Ok - this is what I was wondering just say I have a string as follows:
Code:
This is a long long
lojngoi
sudofi usdfh ksjdhfjk sdhfgkj shgh sdfhg sdfg sdfgdsfg
... I want to specify a maximum width (eg 180) for my string and get the height returned... the picture below explains in more detail:
Thanks
Kris
Re: Measure the height of a string with a FIXED max width
Can't you use a textbox with Multiline = true for that?
Re: Measure the height of a string with a FIXED max width
vb.net Code:
Dim size = myGraphics.MeasureString(myString, myFont, maxWidth)
Dim height = size.Height
Note that MeasureString returns a SizeF, not a Size, so in this case 'height' will be a Single, not an Integer.
Re: [RESOLVED] Measure the height of a string with a FIXED max width
dee-u - not a textbox
jmcilhinney - thanks have used the measure string alot ... just didnt realise you could enter a max with - thanks
Re: [RESOLVED] Measure the height of a string with a FIXED max width
Quote:
Originally Posted by
i00
dee-u - not a textbox
jmcilhinney - thanks have used the measure string alot ... just didnt realise you could enter a max with - thanks
Which is why you read the documentation. I've pretty much never used MeasureString but I was aware of its existence and, when I read your question, it sounded like the obvious choice. I opened my MSDN Library and looked it up. If I could do that then you really should been able to as well, having more experience with MeasureString than I.