TreeView.HitTest Method (Int32, Int32)
Provides node information, given x- and y-coordinates.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The x-coordinate at which to retrieve node information
The y-coordinate at which to retrieve node information.
Return ValueType: System.Windows.Forms.TreeViewHitTestInfo
The node information.
Use this method to determine whether a set of x- and y-coordinates is located in a TreeNode and where within the node the point is located, such as on the label or image area.
The following code example code demonstrates how to use the Level, Node, and HitTest members. 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 the form and associate the MouseDown event of treeView1 with the treeView1_MouseDown method in this example.
Available since 2.0