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 Form 中,並填 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

適用於