Create a bitmap from a RichTextBox

I can guaruntee you that the first solution on the page you linked to won't work. RichTextBox does not support DrawToBitmap. I don't know why it isn't supported but I'm guessing that for the same reasons that RichTextBox doesn't support DrawToBitmap, the second solution might not work either. That's just a guess though.
 
No one said he made it up and no one said don't try it. His program will work just as he said, with the exception that the first method won't work with rtf boxes and the second may not work for rtf boxes. To me, "may not" implies "try it and find out."
 
I've tested both methods on the linked-to page. The most important thing to note is that they do not behave the same way.

The second will copy the image of a control directly off the screen. This means that it will work for a rich text box. The drawback is that since the image is copied from the screen, if the control is not completely visible (i.e. is hidden, partially or completely covered by another control or window, or out of the bounds of the screen or its container) it will not be drawn as excpected.

The first actually gives the control a device context to render to exactly as it would render itself to the screen. This means that a control that supports this function will always draw itself successfully regardless of how it appears on the screen. It also means that you can't use it to draw a RichTextBox because the RichTextBox does not support DrawToBitmap. (It also draws forms as though they are unfocused.)
 
Back
Top