語言

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 確保表格treeview1MouseDown的事件與該方法相關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

適用於