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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top