TreeViewHitTestInfo::Node Property

 

Gets the TreeNode at the position indicated by a hit test of a TreeView control.

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

public:
property TreeNode^ Node {
	TreeNode^ get();
}

Property Value

Type: System.Windows.Forms::TreeNode^

The TreeNode at the position indicated by a hit test of a TreeView control.

If the hit test location is not on a TreeNode, the Node property will be null.

The following code example demonstrates how to use the Node property. To run this example, create a Windows Form that contains a TreeView named treeView1, and populate it with several levels of nodes. Paste the following code into a form, and associate the MouseDown event of treeView1 with the treeView1_MouseDown method.

private:
    void InitialTreeView_MouseDown(Object^ sender, MouseEventArgs^ e)
    {
        TreeViewHitTestInfo^ info = initialTreeView->HitTest(e->X, e->Y);
        TreeNode^ hitNode;

        if (info->Node != nullptr)
        {
            hitNode = info->Node;
            MessageBox::Show(hitNode->Level.ToString());
        }
    }

.NET Framework
Available since 2.0
Return to top
Show: