For the past few weeks I have been playing around with a Windows Form application that I put together and just adding features to it incrementally. I started off with a simple TextBox control, I then changed to using a RichTextBox and finally I wanted to add images to the RichTextBox control. Having a look around for a way to do that I quickly realised that it is not as easy as one would expect it to be.
The easiest way to do it is to programmatically copy/paste the image inside the RichTextBox, but I won't even start on how crappy that solution is. It also lacks considerably in performance so it was never really an option for me.
After some searching I came across this article on The Code Project. It provides the code to insert an image in a RichTextBox control using OLE. This is a much cleaner approach that performs much better than the copy/paste option. I have created my own control that is heavily based on the code of this article so I can use it in all of my Windows Form applications. I thought it would be useful if I posted the source code for it.
Grab it here.