Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

TreeNode.Handle Property

Gets the handle of the tree node.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

[BrowsableAttribute(false)]
public IntPtr Handle { get; }

Property Value

Type: System.IntPtr
The tree node handle.

If a handle is not already created when the Handle property is referenced, it is created.

The following code example gets the TreeNode that was collapsed and creates a copy of it using its Handle property. The original TreeNode is removed from the TreeNodeCollection, and the copy is added to the collection. This example requires that you have a Form with a TreeView control on it. The TreeView control should have two or more root nodes, each having at least one child node.

private void treeView1_AfterCollapse(object sender, TreeViewEventArgs e)
{
   // Create a copy of the e.Node from its Handle.
   TreeNode tn = TreeNode.FromHandle(e.Node.TreeView, e.Node.Handle);
   tn.Text += "Copy";
   // Remove the e.Node so it can be replaced with tn.
   e.Node.Remove();
   // Add tn to the TreeNodeCollection.
   treeView1.Nodes.Add(tn);
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft