Drag a tree view node on to a richedit

  • Thread starter Thread starter Jeremy Chapman
  • Start date Start date
J

Jeremy Chapman

I want to be able to drag a treeview node, drop it on to a rich edit box and
when that event occures, insert some text into the rich edit at the location
that the node was dropped.

Possible? Any hints on how to do this, as I'm not sure where to start.
 
That's simple.

// the handler for the Treeview.ItemDrag event
private void treeview_ItemDrag(object sender,
ItemDragEventArgs e)
{
// create the text you want to drop here
string text = CreateYourTextNow(treeview.SelectedNode);

// perform the drag-drop
DoDragDrop(text, DragDropEffects.Copy);
}

Note: For your RichTextBox, you may have to set AllowDrop to true.

Mark Rockmann
 
Magnificent!

thanks.

StealthyMark said:
That's simple.

// the handler for the Treeview.ItemDrag event
private void treeview_ItemDrag(object sender,
ItemDragEventArgs e)
{
// create the text you want to drop here
string text = CreateYourTextNow(treeview.SelectedNode);

// perform the drag-drop
DoDragDrop(text, DragDropEffects.Copy);
}

Note: For your RichTextBox, you may have to set AllowDrop to true.

Mark Rockmann
 
Back
Top