Export (0) Print
Expand All

TreeNode.FromHandle Method

Returns the tree node with the specified handle and assigned to the specified tree view control.

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

static member FromHandle : 
        tree:TreeView * 
        handle:IntPtr -> TreeNode

Parameters

tree
Type: System.Windows.Forms.TreeView

The TreeView that contains the tree node.

handle
Type: System.IntPtr

The handle of the tree node.

Return Value

Type: System.Windows.Forms.TreeNode
A TreeNode that represents the tree node assigned to the specified TreeView control with the specified handle.

When a node is added to the TreeView.Nodes collection, the TreeView control sends an NM_CUSTOMDRAW notification before the node handle is available. If you override the WndProc method of the TreeView to provide custom drawing in response to this notification, you should always check the return value of this method for a null reference (Nothing in Visual Basic) before you attempt to access the node.

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.

No code example is currently available or this language may not be supported.

.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