TreeView.NodeMouseDoubleClick Evento

Definición

Se produce cuando el usuario hace doble clic con el mouse en un nodo 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 

Tipo de evento

Ejemplos

En el ejemplo de código siguiente se muestra cómo controlar el NodeMouseDoubleClick evento y cómo usar .TreeNodeMouseClickEventArgs Para ejecutar este ejemplo, pegue el código en un formulario Windows Forms que contenga un TreeView elemento denominado treeView1. Rellene treeView1 con los nombres de los archivos ubicados en el c:\ directorio del sistema en el que se ejecuta el ejemplo y asocie el NodeMouseDoubleClick evento de treeView1 con el treeView1_NodeMouseDoubleClick método en este ejemplo. En este ejemplo se requiere que el usuario tenga privilegios de administrador en la máquina que ejecuta el ejemplo.

    // 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

Comentarios

Este evento se produce cuando el usuario hace doble clic en cualquier parte de un nodo de árbol con el mouse, incluido el signo más (+) o el signo menos (-) que indica si el nodo está contraído o expandido.

Para obtener más información sobre el manejo de eventos, consulte controlar y provocar eventos.

Se aplica a

Consulte también