TreeView.NodeMouseDoubleClick イベント

定義

ユーザーがマウスで TreeNode をダブルクリックしたときに発生します。

public:
 event System::Windows::Forms::TreeNodeMouseClickEventHandler ^ NodeMouseDoubleClick;
public event System.Windows.Forms.TreeNodeMouseClickEventHandler NodeMouseDoubleClick;
public event System.Windows.Forms.TreeNodeMouseClickEventHandler? NodeMouseDoubleClick;
member this.NodeMouseDoubleClick : System.Windows.Forms.TreeNodeMouseClickEventHandler 
Public Custom Event NodeMouseDoubleClick As TreeNodeMouseClickEventHandler 

イベントの種類

次のコード例では、 イベントを処理 NodeMouseDoubleClick する方法と を使用する方法を TreeNodeMouseClickEventArgs示します。 この例を実行するには、 という名前treeView1の を含む Windows フォームにコードをTreeView貼り付けます。 サンプルが実行されているシステムのディレクトリにあるc:\ファイルの名前を設定treeView1し、 のtreeView1_NodeMouseDoubleClicktreeView1イベントを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

注釈

このイベントは、ユーザーがマウスでツリー ノードの任意の部分をダブルクリックしたときに発生します。これには、ノードが折りたたまれているか展開されているかを示すプラス記号 (+) またはマイナス記号 (-) が含まれます。

イベントの処理の詳細については、「処理とイベントの発生」を参照してください。

適用対象

こちらもご覧ください