TreeViewHitTestLocations 枚举


定义表示 TreeViewTreeNode 的区域的常量。Defines constants that represent areas of a TreeView or TreeNode.

此枚举有一个 FlagsAttribute 属性,允许按位组合成员值。

public enum class TreeViewHitTestLocations
public enum TreeViewHitTestLocations
type TreeViewHitTestLocations = 
Public Enum TreeViewHitTestLocations


AboveClientArea 256

TreeView 控件的客户端部分之上的位置。A position above the client portion of a TreeView control.

BelowClientArea 512

TreeView 控件的客户端部分之下的位置。A position below the client portion of a TreeView control.

Image 2

TreeViewTreeNode 上包含的图像界限之内的位置。A position within the bounds of an image contained on a TreeView or TreeNode.

Indent 8

TreeNode 的缩进区域中的位置。A position in the indentation area for a TreeNode.

Label 4

TreeNode 的文本部分上的位置。A position on the text portion of a TreeNode.

LeftOfClientArea 2048

TreeView 控件的工作区左侧的位置。A position to the left of the client area of a TreeView control.

None 1

TreeView 控件的工作区中的位置,但不在节点上或节点的某一部分上。A position in the client area of the TreeView control, but not on a node or a portion of a node.

PlusMinus 16

TreeNode 的加/减按钮区域中的位置。A position on the plus/minus area of a TreeNode.

RightOfClientArea 1024

TreeView 控件的工作区右侧的位置。A position to the right of the client area of the TreeView control.

RightOfLabel 32

TreeNode 的文本区域右侧的位置。A position to the right of the text area of a TreeNode.

StateImage 64

TreeNode 的状态图像界限内的位置。A position within the bounds of a state image for a TreeNode.


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

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


TreeViewHitTestLocations 枚举由 TreeViewHitTestInfo 类使用。The TreeViewHitTestLocations enumeration is used by the TreeViewHitTestInfo class.