To best of my knowledge, such operation is not supported by the
RichTextBox
classes (and I don't know what class do you mean exactly; please see my comment to the question: you should specify it exactly — always). So, the only way I can see is using clipboard.
In your
DragDrop
event handler you should do something like this:
myRichTextBox.DragDrop += (sender, eventArgs) => {
RichTextBox richTextBox = (RichTextBox)sender;
Image image = eventArgs.???
Clipboard.SetImage(image);
richTextBox.Paste();
}
Again, it depends on what UI library you use (tag it — always!), but you should get the picture. :-)
Sorry the code above is not exact code you will need.
This is because you did not specify exact class of
RichTextBox
and UI library. Please, based on this idea, go to MSDN help and find exact types and methods to use. With different .NET UI libraries, they are somewhat similar but different.
[EDIT]
I recently found the solution for inserting images in
System.Windows.Forms.RichTextBox
; it is based on Clipboard. This is not a very good support, so I also offered an interesting alternative I tested and found great. Please see my recent answer:
how to open word file with images and bullets in a rich text box[
^].
—SA