Basically my issue is that I need to word wrap a string when I want to. Not when .NET wants to. I und开发者_JS百科erstand that the DrawString method will automatically word wrap if I give it a rectangle to draw within. I need to control when it does word wrap it. So lets say my string I want to draw is Testing 1234. And I want to draw text on a new line whenever I see a space. So in this case it would have two lines - Testing and 1234. I am guessing I need a combination of re-sizing the string (to fit my bounds) and multiple drawstring method calls to draw each line. The problem is that I don't really know how to do this. I am a novice when it comes to GDI+.
You could replace the spaces with newlines and then draw the string.
string converted = text.Replace(" ", System.Environment.NewLine);
精彩评论