When the file of one of the supported formats is dropped on the RichEditControl, its content is completely replaced with this file content. But what if you wish to insert this file content into a drop position in the document? To achieve this goal, set the RichEditControl.Options.Behavior.Drop property (see RichEditBehaviorOptions.Drop) to DocumentCapability.Disabled, and handle drag-and-drop operations in a custom manner (see the How to perform drag-and-drop operation in a custom manner example). The most interesting place in this example is the richEditControl1_DragDrop event handler (method). Note the manner in which the non-visual RichEditDocumentServer component is utilized to load dropped file in memory. Then, the loaded document is inserted into a target RichEditControl via the SubDocument.InsertDocumentContent Method.
Question Comments
Added By: Grégory Bastogne at: 12/6/2012 4:01:00 AM
This example works fine for doc, txt, rtf documents and the like but it doesn't work with pictures. It tries to make some xml out of it with some 'Adobe Fireworks CS3' information and 'RDF' and 'xap' tags. That was with a small PNG. I also tried with a bigger JPG and it ended up with a thread deadlock.
The generated xml-like code for the PNG cannot even be entirely copied to the clipboard as is.
Added By: Grégory Bastogne at: 12/6/2012 4:03:44 AMI mean ok 'LoadDocument' is supposed to load a document not a picture. But when you normally drop a picture to a 'RichEditControl' it converts it to RTF and displays it. I was expecting the same behaviour here.
Added By: Max Reimann at: 9/19/2016 11:30:40 PM Hello,i was testing your Example with Version16.1
If you try to drag and drop an image you will get
"System.NullReferenceException" in DevExpress.RichEdit.v16.1.Core.dll
Source of this exception is the richEditControl1_DragOver methode Line
which returns null if you are not within the Text[C#]DocumentPositionpos=richEditControl1.GetPositionFromPoint(docPoint);
Also does the drop result doesn't look like it should look like this (i was expecting an image instead of a cryptical text)
So my question's are, is the return of null right at this place and is the cryptical text a expected behavior? Added By: Andrey (DevExpress Support) at: 9/20/2016 1:31:53 AM
Hello,
To process your inquiry in the most efficient manner, I've created a separate ticket on your behalf (T429449: The System.NullReferenceException is thrown in the E3489 example when dragging outside the RichEdit control). It has been placed in our processing queue and will be answered shortly.