Browse by Tags
All Tags » TreeView (RSS)
-
|
When you drag an item within the TreeView, you can handle the DragOver event for a drag-drop. If you want to drag-drop into a spot that's not currently visible, you can scroll the TreeView by handling the DragOver event: [C#] private void treeView1_DragOver...
|
-
|
Set the TreeView.CheckBoxes property to true. Contributed from George Shepherd's Windows Forms FAQ
|
-
|
Handle the TreeView's MouseDown event, and if it is the right-click, then explicitly set focus to the node under the click. private void treeView1_MouseDown( object sender, MouseEventArgs e ) { if ( e.Button == MouseButtons.Right ) treeView1.SelectedNode...
|
-
|
When I get the SelectedNode in the TreeView's Click event, it is the previous selection. How do I get the newly selected node? Use the AfterSelect event instead of the Click event. The Click event is inherited from Control.Click and occurs before...
|
-
|
Try using a MouseMove event handler and checking to see if you have moved to a new node, and if so, set a new tiptext. [C#] private int oldNodeIndex = -1; private ToolTip toolTip1; private void Form1_Load( object sender, EventArgs e ) { toolTip1 = new...
|
-
|
[C#] public int NodeLevel( TreeNode node ) { int level = 0; while ( (node = node.Parent) != null ) ++level; return level; } [Visual Basic] Public Sub NodateLevel(ByVal node as TreeNode) As Integer Dim level as Integer = 0 While Not node Is Nothing node...
|
-
|
The following code snippet demonstrates how you can clone or copy all the nodes in TreeView1 to TreeView2 by clicking on Button1. private void IterateTreeNodes( TreeNode originalNode, TreeNode rootNode ) { foreach ( TreeNode childNode in originalNode...
|
-
|
// Select the first node treeView1.SelectedNode = treeView1.Nodes[0]; Contributed from George Shepherd's Windows Forms FAQ
|
-
|
You can display a context menu when a user right-clicks on a node by handling the TreeView's MouseUp event as shown below: [C#] private void treeView1_MouseUp( object sender, MouseEventArgs e ) { if ( e.Button == MouseButtons.Right ) { Point clickPoint...
|
-
|
A click event will be fired but a node will not be selected when the user clicks to the right of a node. This code snippets show how you can ensure that a node is selected in this scenario: private void treeView1_Click( object sender, EventArgs e ) {...
|
-
|
Here are some VB.Net code snippets to handle the DragEnter, ItemDrag and DragDrop events that provide a solution to this problem. You can get C# code in this sample, TreeViewDnD . Here is some sample handlers. private void treeView2_DragDrop( object sender...
|
-
|
The Treeview control does not support multiple selections but here is sample which demonstrates how this feature can be implemented. Another sample is available at C# .NET TreeView with multiple selection at arsdesign.com . Contributed from George Shepherd's...
|
-
|
The following articles on MSDN give you step by step instructions on how you can populate a TreeView Control with data from an XML document. How To Populate a TreeView Control with XML Data in Visual Basic .NET (Article ID: 308063) HOW TO: Populate a...
|