You could use a third-party control for this (maybe), but here are some reasons why this is potentially a bad idea:
- third-party controls cost money
- third-party controls tend to suck
- third-party controls require you to distribute at least an additional DLL, over which you usually have no control
- even if the third-party control can ultimately do what you need, it will take you some time and effort to figure out how to use it, and how to hammer it into the shape you require
For anything out of the ordinary (like what you're doing), writing your own UserControl is the best way to go, for these (among others) reasons:
- writing your own UserControl is far and away the most fun thing you can do in .Net
- you will have to learn some things to do this well, but the knowledge you gain is immediately transferable to other problems and projects (whereas whatever you learn about using Initrode's Infinite Wonderfulness Gridifier will only ever help you with using that particular control)
- there will be nothing additional to distribute with your application
- complete control over the source code
- free forever (with apologies to Evony)
- the sky is the limit - with any third-party control, you will ultimately run into something that it just can't do, but if you're doing it yourself, you can literally do anything you want
Your particular problem (well described in your question, thanks to the graphics) is quite easy to do as a mostly owner-drawn UserControl (with a TextBox or two thrown in the mix). The only methods you'll need from the System.Drawing.Graphics object are DrawRectangle, FillRectangle, MeasureString and DrawString. You won't even need any documentation, as Intellisense will give you everything you need.
If you run into trouble, I'll write it for you for a chocolate chip cookie. :)
Update: since you need the text to all be selectable, that makes this approach a bit more complicated. Implementing your own Textbox-type functionality is a gigantic pain in the petard, but a relatively simple solution is to add a real multi-line Textbox over top of any text-containing rectangle when the user clicks on it, and to put the rectangle's text (pre-selected) into the Textbox. When this temporary Textbox loses focus (LostFocus), you draw the edited text into the rectangle and delete the Textbox. This way you only have one Textbox at a time in your UserControl.
This version will cost you two cookies.
Update 2: Here is a simple application that demonstrates how to use a single TextBox to make your entire control selectable and editable. And here is the source code.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…