語言

TreeNodeMouseClickEventArgs 類別

定義

提供 NodeMouseClick 和 NodeMouseDoubleClick 事件的數據。

public ref class TreeNodeMouseClickEventArgs : System::Windows::Forms::MouseEventArgs
public class TreeNodeMouseClickEventArgs : System.Windows.Forms.MouseEventArgs
type TreeNodeMouseClickEventArgs = class
    inherit MouseEventArgs
Public Class TreeNodeMouseClickEventArgs
Inherits MouseEventArgs
繼承
TreeNodeMouseClickEventArgs

範例

以下程式碼範例示範如何處理事件 NodeMouseDoubleClick 及如何使用 TreeNodeMouseClickEventArgs。 執行此範例時,將程式碼貼入包含 TreeViewtreeView1 的 Windows 表單。 輸入treeView1範例c:\執行系統目錄中檔案名稱,並將事件 與NodeMouseDoubleClicktreeView1此範例中的方法關聯treeView1_NodeMouseDoubleClick起來。

    // If a node is double-clicked, open the file indicated by the TreeNode.
private:
    void InitialTreeView_NodeMouseDoubleClick(Object^ sender,
        TreeNodeMouseClickEventArgs^ e)
    {
        try
        {
            // Look for a file extension.
            if (e->Node->Text->Contains("."))
            {
                System::Diagnostics::Process::Start("c:\\" + e->Node->Text);
            }
        }
        // If the file is not found, handle the exception and inform the user.
        catch (System::ComponentModel::Win32Exception^)
        {
            MessageBox::Show("File not found.");
        }
    }
// If a node is double-clicked, open the file indicated by the TreeNode.
void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
    try
    {
        // Look for a file extension.
        if (e.Node.Text.Contains("."))
            System.Diagnostics.Process.Start(@"c:\" + e.Node.Text);
    }
        // If the file is not found, handle the exception and inform the user.
    catch (System.ComponentModel.Win32Exception)
    {
        MessageBox.Show("File not found.");
    }
}
' If a node is double-clicked, open the file indicated by the TreeNode.
Sub treeView1_NodeMouseDoubleClick(ByVal sender As Object, _
    ByVal e As TreeNodeMouseClickEventArgs) _
    Handles treeView1.NodeMouseDoubleClick

    Try
        ' Look for a file extension, and open the file.
        If e.Node.Text.Contains(".") Then
            System.Diagnostics.Process.Start("c:\" + e.Node.Text)
        End If
        ' If the file is not found, handle the exception and inform the user.
    Catch
        MessageBox.Show("File not found.")
    End Try

End Sub

建構函式

名稱 Description
TreeNodeMouseClickEventArgs(TreeNode, MouseButtons, Int32, Int32, Int32)

初始化 TreeNodeMouseClickEventArgs 類別的新執行個體。

屬性

名稱 Description
Button

會知道是哪個滑鼠按鍵被按下的。

(繼承來源 MouseEventArgs)
Clicks

會顯示滑鼠按鍵被按下和放開的次數。

(繼承來源 MouseEventArgs)
Delta

會得到滑鼠滾輪旋轉的卡位數,並乘以WHEEL_DELTA常數。 卡位是滑鼠滾輪的一個刻度。

(繼承來源 MouseEventArgs)
Location

取得生成事件期間滑鼠的位置。

(繼承來源 MouseEventArgs)
Node

會取得被點擊的節點。

X

在生成滑鼠事件期間取得滑鼠的 x 座標。

(繼承來源 MouseEventArgs)
Y

在生成滑鼠事件期間取得滑鼠的 y 座標。

(繼承來源 MouseEventArgs)

方法

名稱 Description
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設哈希函式。

(繼承來源 Object)
GetType()

取得目前實例的 Type。

(繼承來源 Object)
MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
ToString()

傳回表示目前 物件的字串。

(繼承來源 Object)

適用於