TreeNodeMouseClickEventArgs.Node 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取被单击的节点。
public:
property System::Windows::Forms::TreeNode ^ Node { System::Windows::Forms::TreeNode ^ get(); };
public System.Windows.Forms.TreeNode Node { get; }
public System.Windows.Forms.TreeNode? Node { get; }
member this.Node : System.Windows.Forms.TreeNode
Public ReadOnly Property Node As TreeNode
属性值
被单击的 TreeNode。
示例
下面的代码示例演示如何处理 NodeMouseDoubleClick 事件以及如何使用 TreeNodeMouseClickEventArgs。 若要运行此示例,请将代码粘贴到包含名为 treeView1
的 TreeView Windows 窗体中。
treeView1
使用运行示例的系统目录中的文件c:\
名称填充 ,并将 的事件与treeView1_NodeMouseDoubleClick
此示例中的 方法相关联NodeMouseDoubleClicktreeView1
。
// 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