TreeViewHitTestInfo.Location 属性

定义

获取 TreeView 控件上的命中测试的位置(相对于 TreeView 及其包含的节点)。

public:
 property System::Windows::Forms::TreeViewHitTestLocations Location { System::Windows::Forms::TreeViewHitTestLocations get(); };
public System.Windows.Forms.TreeViewHitTestLocations Location { get; }
member this.Location : System.Windows.Forms.TreeViewHitTestLocations
Public ReadOnly Property Location As TreeViewHitTestLocations

属性值

TreeViewHitTestLocations 值之一。

示例

下面的代码示例演示如何使用 Location 属性。 若要运行此示例,请将以下代码粘贴到包含 TreeView 名为 的 treeView1控件的 Windows 窗体中 TreeView ,并使用项填充 。 确保 treeview1 窗体的 MouseDown 和 事件与 HandleMouseDown 方法相关联。

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

适用于