TreeView.NodeMouseDoubleClick Olay

Tanım

Kullanıcı fareyle bir TreeNode öğesine çift tıkladığında gerçekleşir.

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 

Olay Türü

Örnekler

Aşağıdaki kod örneği, olayın nasıl işleneceğini NodeMouseDoubleClick ve nasıl kullanılacağını TreeNodeMouseClickEventArgsgösterir. Bu örneği çalıştırmak için, kodu TreeView adlı treeView1 içeren bir Windows Formuna yapıştırın. Örneğin üzerinde çalıştığı sistemin dizininde treeView1 bulunan dosyaların adlarıyla doldurun c:\ ve olayını NodeMouseDoubleClick bu örnekteki treeView1 yöntemiyle ilişkilendirintreeView1_NodeMouseDoubleClick. Bu örnek, kullanıcının örneği çalıştıran makinede yönetici ayrıcalıklarına sahip olmasını gerektirir.

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

Açıklamalar

Bu olay, kullanıcı fareyle bir ağaç düğümünün herhangi bir bölümüne çift tıkladığında, düğümün daraltıldığını veya genişletildiğini gösteren artı işareti (+) veya eksi işareti (-) dahil olmak üzere oluşur.

Olayları işleme hakkında daha fazla bilgi için bkz . Olayları İşleme ve Oluşturma.

Şunlara uygulanır

Ayrıca bkz.