This example illustrates how to perform the drag-and-drop operation in case of a ListBox drag-and-drop source. Since there is no built-in capability to accomplish this task, you should perform the drag-and-drop operation in a custom manner. To do this, use the following RichEditControl events: DragEnter, DragOver, DragDrop. Most part of the work is performed in the DragOver event handler. Here, you should update the RichEditControl.Document.CaretPosition property value according to the current mouse position (use the approach from the How to: Obtain the Document Position under the Mouse Cursor) help section for this purpose). Also, you might want to draw a custom insertion marker in this event handler. Otherwise, you can use the standard caret. In latter case, just call the RichEditControl.Focus() method in the control's DragEnter event handler. Finally, note how the RichEditControl.ScrollToCaret Method is used to scroll the document to the caret position if you move the caret outside of the visible document area.
Question Comments
Added By: Sandesh Prabhudesai 1 at: 12/8/2015 12:43:09 PM
I used the vb code you have listed below to drag rtffile/rtftext . However, when it enters the DragDrop event, if I check the richEditControl1.RtfText, it shows that the text I am dragging is already pasted in it.
This causes it to paste the text twice. The method InsertRtfText I am calling puts the text correctly, But the text added by the event automatically has rtftext in it.
For example Here is the text added by default
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}
\viewkind4\uc1\pard\f0\fs17 We appreciate your business!\par
}
Here is the text added by my InsertRtfText method call
We appreciate your business!
Please help.
Sandesh