Actualización: noviembre 2007
Proporciona los datos de los eventos NodeMouseClick y NodeMouseDoubleClick.
Ensamblado: System.Windows.Forms (en System.Windows.Forms.dll)
Public Class TreeNodeMouseClickEventArgs _ Inherits MouseEventArgs
Dim instance As TreeNodeMouseClickEventArgs
public class TreeNodeMouseClickEventArgs : MouseEventArgs
public ref class TreeNodeMouseClickEventArgs : public MouseEventArgs
public class TreeNodeMouseClickEventArgs extends MouseEventArgs
public class TreeNodeMouseClickEventArgs extends MouseEventArgs
En el siguiente ejemplo de código se muestra cómo controlar el evento NodeMouseDoubleClick y cómo utilizar TreeNodeMouseClickEventArgs. Para ejecutar este ejemplo, pegue el código en un formulario Windows Forms que contenga un control TreeView denominado treeView1. Rellene el control treeView1 con los nombres de archivos ubicados en el directorio c:\ del sistema en el que se esté ejecutando el ejemplo y asocie el evento NodeMouseDoubleClick de treeView1 al método treeView1_NodeMouseDoubleClick de este ejemplo.
' 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 'treeView1_NodeMouseDoubleClick
// 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.
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.");
}
}
System.EventArgs
System.Windows.Forms.MouseEventArgs
System.Windows.Forms.TreeNodeMouseClickEventArgs
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.