The basic similarity in the XML file and treeview control is the representation of the data in a hierarchical format. So we can bind the treeview control from the XML file. In this article i will explain you how we can do it. Continue reading “Bind Treeview from xml file at runtime in C#”
Tag: TreeView control
How to show all drives and their folders in treeview control with checkboxes
In this article i will show how we can bind all logical drives of your computer with their sub directories using vb.net programming languages.
The following example requires a Treeview control named Treeview1. Continue reading “How to show all drives and their folders in treeview control with checkboxes”
Drag and drop a tree node from one node another node in c#
This article demonstrate how we can add drag and drop functionality in one Treeview or between two or more Treeview controls. The following example shows how we can how we can drag and drop one treenode to other node of the treeview control.
below example contains two treeview named treeView1 and treeView2. you need to set the AllowDrop property of both TreeView1 and TreeView2 to True in the Properties window. In this example we are using common drag and drop events.
public Form1() { InitializeComponent(); TreeNode ParentNode1; TreeNode ParentNode2; TreeNode ParentNode3; ParentNode1 = treeView1.Nodes.Add("Fruits"); ParentNode1.Nodes.Add("Apple"); ParentNode1.Nodes.Add("Banana"); ParentNode1.Nodes.Add("Mango"); ParentNode1.Nodes.Add("Graps"); ParentNode1.Expand(); ParentNode3 = treeView1.Nodes.Add("Colors"); ParentNode3.Nodes.Add("Red"); ParentNode3.Nodes.Add("Yellow"); ParentNode3.Nodes.Add("Green"); ParentNode3.Expand(); ParentNode2 = treeView2.Nodes.Add("Store"); ParentNode2.Nodes.Add("Store1"); ParentNode2.Nodes.Add("Store2"); ParentNode2.Expand(); this.treeView1.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeView_ItemDrag); this.treeView2.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeView_ItemDrag); this.treeView1.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeView_DragEnter); this.treeView2.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeView_DragEnter); this.treeView1.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeView_DragDrop); this.treeView2.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeView_DragDrop); } private void treeView_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e) { DoDragDrop(e.Item, DragDropEffects.Move); } private void treeView_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) { e.Effect = DragDropEffects.Move; } private void treeView_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { TreeNode NewNode; if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false)) { Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y)); TreeNode DestinationNode = ((TreeView)sender).GetNodeAt(pt); NewNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); //if (DestinationNode.TreeView != NewNode.TreeView) //{ DestinationNode.Nodes.Add((TreeNode)NewNode.Clone()); DestinationNode.Expand(); //Remove Original Node NewNode.Remove(); // } } }
Drag and drop operation between two treeview using vb.net
The following example demonstrates how to perform a drag and drop operation with tree nodes between two TreeView controls in vb.net
Continue reading “Drag and drop operation between two treeview using vb.net”
Drag and drop from treeview to textbox in vb.net
Drag and drop operation is the same as cut and paste (or copy and paste) through the mouse instead of the keyboard.
Continue reading “Drag and drop from treeview to textbox in vb.net”
Example : treeview control at runtime in vb.net
The following example code bind the nodes to the existing treeview at run time in vb.net.
Continue reading “Example : treeview control at runtime in vb.net”
Display directory and its all sub directories in treeview in vb.net
Display directory and its all sub directories in treeview in vb.net
Continue reading “Display directory and its all sub directories in treeview in vb.net”
Add ContextMenu to treeview nodes in c#
In this article we will learn that how to add contextmenu or contextmenustrip in treeview nodes at design time as well as runtime using c# programming language.
Continue reading “Add ContextMenu to treeview nodes in c#”
Add ContextMenu to treeview nodes in vb.net
In this article we will learn that how to add contextmenu or contextmenustrip in treeview nodes at design time as well as runtime using vb.net programming language.
Continue reading “Add ContextMenu to treeview nodes in vb.net”
Create Treeview from Datatable in c#
In this article we will learn that how to create TreeView control from datatable object in c# programming language.
Continue reading “Create Treeview from Datatable in c#”