TreeNode.Handle Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the handle of the tree node.
public:
property IntPtr Handle { IntPtr get(); };
public IntPtr Handle { get; }
[System.ComponentModel.Browsable(false)]
public IntPtr Handle { get; }
member this.Handle : nativeint
[<System.ComponentModel.Browsable(false)>]
member this.Handle : nativeint
Public ReadOnly Property Handle As IntPtr
nativeint
The tree node handle.
- Attributes
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 = String::Concat( 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 );
}
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);
}
Private Sub treeView1_AfterCollapse(sender As Object, _
e As TreeViewEventArgs) Handles treeView1.AfterCollapse
' Create a copy of the e.Node from its Handle.
Dim tn As TreeNode = 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)
End Sub
If a handle is not already created when the Handle property is referenced, it is created.
Продукт | Версії |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
Відгук про .NET
.NET – це проект із відкритим кодом. Виберіть посилання, щоб надати відгук: