This is a migrated thread and some comments may be shown as answers.

Is dragging and dropping an image into the RichTextBox supported?

1 Answer 134 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 30 Jul 2014, 11:31 AM
Is dragging and dropping an image into the RichTextBox supported? It doesn't work out-of-the-box and I've always tried the TelerikEditorDemo_WPF example without luck. Scenario: Dragging an image from the desktop and dropping it into the RichTextBox.

1 Answer, 1 is accepted

Sort by
0
Aylin
Telerik team
answered on 04 Aug 2014, 10:57 AM
Hello Martin,

Thank you for contacting us. 

Image drag-and-drop is not supported out-of-the-box in RichTextBox but you could easily implement it using the Drop event handler. Here is an example implementation: 

private void radRichTextBox_Drop(object sender, DragEventArgs e)
{
    string[] droppedFiles = e.Data.GetData(DataFormats.FileDrop) as string[];
 
    foreach (string droppedFile in droppedFiles)
    {      
        using (Stream imageStream = File.OpenRead(droppedFile))
        {
            this.radRichTextBox.InsertImage(imageStream, Path.GetExtension(droppedFile));
        }
                 
    }
}

I hope this helps.

Regards,
Aylin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
RichTextBox
Asked by
Martin
Top achievements
Rank 1
Answers by
Aylin
Telerik team
Share this question
or