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. Чтобы запустить этот пример, вставьте код в форму Windows, содержащую TreeView с именем treeView1. treeView1 Заполните имена файлов, расположенных в c:\ каталоге системы, в котором выполняется пример, и свяжите NodeMouseDoubleClick событие treeView1 с методом 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

Комментарии

Это событие возникает, когда пользователь дважды щелкает любую часть узла дерева с помощью мыши, включая знак плюса (+) или знак минуса (-), указывающий, свернут или развернут узел.

Дополнительные сведения об обработке событий см. в разделе "Обработка и создание событий".

Применяется к

См. также раздел