Hi Nagarajan,
Thanks for the reply, actually there were few modifications in my questions. I want to check multiple nodes and then i want to click a delete button so that it removes all the checked nodes, same way for selected.
Or else assume that you are moving nodes from treeview to listbox. There i want to select whatever the treenodes i want and then click a button to move the items to the list box.
Deleting a single node is quite simple.
Thanks in advance.
>Hi Hemanth,
1. If you want to remove the the nodes using dragdrop then you can handle treeViewAdv_DragDrop event and you can remove the dropped node. Please refer to the following code snippet.
private void treeViewAdv_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
TreeViewAdv treeView = sender as TreeViewAdv;
// Get the destination and source node.
TreeNodeAdv sourceNode = (TreeNodeAdv) e.Data.GetData(typeof(TreeNodeAdv));
treeView.SelectedNode = sourceNode;
this.treeViewAdv1.Nodes.Remove(sourceNode);
}
I have attached the sample that demonstrates this completely. In the same when you drag and drop the node to another loacation, the dropped node gets deleted. You can download the sample from the following page.
http://websamples.syncfusion.com/samples/Tools.Windows/TreeDragDrop/main.htmPlease let me know if you have any questions.
2. If you want to remove the checked nodes then you have to handle AfterCheck event of the treeview. Please refer to the following code snippet
private void treeViewAdv1_AfterCheck(object sender, Syncfusion.Windows.Forms.Tools.TreeNodeAdvEventArgs e)
{
e.Node.Remove();
}
3. If you want to remove the selected nodes then you can write a delegate for NodeSelection event. I have attached the sample that demonstrates this completely. In this sample when you select the node by mouse click or by key selection, then the selection node gets deleted.
http://websamples.syncfusion.com/samples/Tools.Windows/RemoveNodes/main.htm4.
a. If you want to add a node using dragdrop then you can handle treeViewAdv_DragDrop event and you can add the dropped node. Please refer to the following code snippet.
TreeNodeAdv sourceNode = (TreeNodeAdv) e.Data.GetData(typeof(TreeNodeAdv));
TreeNodeAdv destinationNode = this.treeViewDragHighlightTracker.HighlightNode;
TreeViewDropPositions dropPosition = this.treeViewDragHighlightTracker.DropPosition;
TreeNodeAdv Node = sourceNode.Clone();
Node.Move(destinationNode, NodePositions.Previous);
this.treeViewAdv1.Nodes.Add(Node);
Please refer to the attached sample that demonstrates this completely.
http://websamples.syncfusion.com/samples/Tools.Windows/AddNodes/main.htmb. If you want to remove the checked nodes then you have to handle AfterCheck event of the treeview. Please refer to the following code snippet
private void treeViewAdv1_AfterCheck(object sender, Syncfusion.Windows.Forms.Tools.TreeNodeAdvEventArgs e)
{
treeView1.Nodes.Add(e.Node);
}
c. If you want to add the selected nodes then you can write a delegate for NodeSelection event. I have attached the sample that demonstrates this completely. In this sample when you select the node by mouse click or by key selection, then the selection node gets added.
http://websamples.syncfusion.com/samples/Tools.Windows/AddSelectedNodes/main.htmPlease let me know if you have any questions.
Thanks,
Nagaraj