I want to draw some text to the side of a vertical line. The text could be anything. The vertical line has a limited length. According to this link ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/CPref17/html/T_System_Windows_Forms_TextRenderer.htm "The DrawText methods of TextRenderer are not supported for printing. You should always use the DrawString methods of the Graphics class." I want to use the same procedure both on screen and for printing, so it seems I should use the DrawString methods, not the TextRenderer.
I don't want the text to appear on just one line if it consists of more than one word, as it could then be too wide. I'd like it to appear on as many lines as possible within the vertical extent of the line. So I could draw the text with DrawString, setting a layoutRectangle parameter. The rectangle could be as high as the line is long. But I don't want it to be too wide or all of the text will be on one line. Moreover I want to ensure that no words are wrapped across lines.
There doesn't seem to be any easy way to achieve this. I could set the width of the rectangle to be the same as the width required for the longest word in the text but that still doesn't guarantee that other words won't be broken up on other lines. I suppose I could analyse the space required for each word in the text and work from there, but that seems very laborious. Or maybe I could use a hidden richtext box. That won't break words up, so I could just adjust that as necessary and copy its size.
So any suggestions before I leap into this?
I don't want the text to appear on just one line if it consists of more than one word, as it could then be too wide. I'd like it to appear on as many lines as possible within the vertical extent of the line. So I could draw the text with DrawString, setting a layoutRectangle parameter. The rectangle could be as high as the line is long. But I don't want it to be too wide or all of the text will be on one line. Moreover I want to ensure that no words are wrapped across lines.
There doesn't seem to be any easy way to achieve this. I could set the width of the rectangle to be the same as the width required for the longest word in the text but that still doesn't guarantee that other words won't be broken up on other lines. I suppose I could analyse the space required for each word in the text and work from there, but that seems very laborious. Or maybe I could use a hidden richtext box. That won't break words up, so I could just adjust that as necessary and copy its size.
So any suggestions before I leap into this?