TreeView.NodeMouseDoubleClick Evento
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Ocorre quando o utilizador faz duplo clique em a TreeNode com o rato.
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
Exemplos
O exemplo de código seguinte demonstra como lidar com o NodeMouseDoubleClick evento e como usar o TreeNodeMouseClickEventArgs. Para executar este exemplo, cole o código num formulário Windows que contenha um TreeView chamado treeView1. Preenche treeView1 com os nomes dos ficheiros localizados no c:\ diretório do sistema onde a amostra está a correr e associa o NodeMouseDoubleClick evento de treeView1 ao treeView1_NodeMouseDoubleClick método deste exemplo. Este exemplo exige que o utilizador tenha privilégios de administrador na máquina a executar o exemplo.
// 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
Observações
Este evento ocorre quando o utilizador faz duplo clique em qualquer parte de um nó da árvore com o rato, incluindo o sinal de mais (+) ou menos (-) que indica se o nó está colapsado ou expandido.
Para obter mais informações sobre como manipular eventos, consulte Manipulando e gerando eventos.