This example illustrates how to perform the drag-and-drop operation in case of a list box.
To do this, handle the following RichEditControl events:
DragEnter
DragOver
DragDrop
In the DragOver event handler, update the RichEditControl.Document.CaretPosition property value according to the current mouse position. Also, you might want to draw a custom insertion marker in this event handler.
If you use the standard caret, call the RichEditControl.Focus()
method in the DragEnter
event handler. Use the RichEditControl.ScrollToCaret method to scroll the document to the caret position if you move the caret outside of the visible document area.
- Form1.cs (VB: Form1.vb)
- Program.cs (VB: Program.vb)