[C#] 纯文本查看 复制代码
private void treeViewMenu_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
Point ClickPoint = new Point(e.X, e.Y);
TreeNode CurrentNode = treeViewMenu.GetNodeAt(ClickPoint);
if (CurrentNode != null)//判断你点的是不是一个节点
{
switch (CurrentNode.Name)//根据不同节点显示不同的右键菜单,当然你可以让它显示一样的菜单
{
case "website":
CurrentNode.ContextMenuStrip = ContentMenuDiy;
break;
case "company":
CurrentNode.ContextMenuStrip = ConentMenuMid;
break;
case "listItem":
CurrentNode.ContextMenuStrip = ContentMenuIthen;
break;
}
treeViewMenu.SelectedNode = CurrentNode;//选中这个节点
}
}
}