TreeViewHitTestInfo TreeViewHitTestInfo TreeViewHitTestInfo TreeViewHitTestInfo Class


包含有关 TreeView 控件的区域或 TreeNode 的信息。Contains information about an area of a TreeView control or a TreeNode.

public ref class TreeViewHitTestInfo
public class TreeViewHitTestInfo
type TreeViewHitTestInfo = class
Public Class TreeViewHitTestInfo


下面的代码示例演示如何使用TreeViewHitTestInfo类。The following code example demonstrates how to use the TreeViewHitTestInfo class. 若要运行此示例, 请将以下代码粘贴到包含TreeView名为treeView1的控件的 Windows 窗体中TreeView , 并填充 with 项。To run this example, paste the following code into a Windows Form that contains a TreeView control named treeView1, and populate the TreeView with items. treeview1确保和HandleMouseDown窗体的事件与方法相关联。MouseDownEnsure that treeview1 and the MouseDown event for the form are associated with the HandleMouseDown method.

void HandleMouseDown(object sender, MouseEventArgs e)
    TreeViewHitTestInfo info = treeView1.HitTest(e.X, e.Y);
    if (info != null)
        MessageBox.Show("Hit the " + info.Location.ToString());
Private Sub HandleMouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) _
    Handles Me.MouseDown, treeView1.MouseDown
    Dim info As TreeViewHitTestInfo = treeView1.HitTest(e.X, e.Y)
    If (info IsNot Nothing) Then
        MessageBox.Show("Hit the " + info.Location.ToString())
    End If

End Sub


当调用方法HitTest时, TreeView由类返回。 TreeViewHitTestInfoThe TreeViewHitTestInfo is returned by the TreeView class when the HitTest method is called.


TreeViewHitTestInfo(TreeNode, TreeViewHitTestLocations) TreeViewHitTestInfo(TreeNode, TreeViewHitTestLocations) TreeViewHitTestInfo(TreeNode, TreeViewHitTestLocations) TreeViewHitTestInfo(TreeNode, TreeViewHitTestLocations)

初始化 TreeViewHitTestInfo 类的新实例。Initializes a new instance of the TreeViewHitTestInfo class.


Location Location Location Location

获取 TreeView 控件上的命中测试的位置(相对于 TreeView 及其包含的节点)。Gets the location of a hit test on a TreeView control, in relation to the TreeView and the nodes it contains.

Node Node Node Node

获取位于由 TreeNode 控件的命中测试所指示的位置的 TreeViewGets the TreeNode at the position indicated by a hit test of a TreeView control.


Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)