TreeViewHitTestInfo.Location 屬性


取得 TreeView 控制項上的點擊測試位置,會與 TreeView 及其所含的節點相關。Gets the location of a hit test on a TreeView control, in relation to the TreeView and the nodes it contains.

 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 值。One of the TreeViewHitTestLocations values.


下列程式碼範例示範如何使用 Location 屬性。The following code example demonstrates how to use the Location property. 若要執行此範例,請將下列程式碼貼入包含名為之控制項的 Windows Form 中, TreeView treeView1 並在中填入 TreeView 專案。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. 確定 treeview1MouseDown 表單的事件都與方法相關聯 HandleMouseDownEnsure 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