TreeViewHitTestInfo.Node Property
Definition
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.
public:
property System::Windows::Forms::TreeNode ^ Node { System::Windows::Forms::TreeNode ^ get(); };
public System.Windows.Forms.TreeNode Node { get; }
public System.Windows.Forms.TreeNode? Node { get; }
member this.Node : System.Windows.Forms.TreeNode
Public ReadOnly Property Node As TreeNode
Property Value
The TreeNode at the position indicated by a hit test of a TreeView control.
Examples
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());
}
}
void treeView1_MouseDown(object sender, MouseEventArgs e)
{
TreeViewHitTestInfo info = treeView1.HitTest(e.X, e.Y);
TreeNode hitNode;
if (info.Node != null) {
hitNode = info.Node;
MessageBox.Show(hitNode.Level.ToString());
}
}
Sub treeView1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim info As TreeViewHitTestInfo = treeView1.HitTest(e.X, e.Y)
Dim hitNode As TreeNode
If (info.Node IsNot Nothing) Then
hitNode = info.Node
MessageBox.Show(hitNode.Level.ToString())
End If
End Sub
Remarks
If the hit test location is not on a TreeNode, the Node property will be null
.