private void myNeTree_MouseDown(object sender, MouseEventArgs e)
{
MyTreeView mtreev = (MyTreeView)sender;
if(e.Button == MouseButtons.Right)
{
if (this.myNeTree.SelectedNode != null && this.myNeTree.SelectedNode.Nodes.Count == 0)
{
Point p = new Point(e.X,e.Y);
TreeNode tn = mtreev.GetNodeAt(p);//根据鼠标右键点下的位置,得到该位置的节点
if(myNeTree.SelectedNode.Equals(tn))//看当前鼠标位置所在的节点是否为当前控件树中选中的节点
{
this.rightMenu.Show(mtreev, p.X, p.Y);
}
}
}
}
因为MyTreeView 是动态加载:
private MyTreeView myNeTree;
ControlContainerItem contNe = new ControlContainerItem("myNeTree", "网元");
myNeTree = new BurEmluator.MyTreeView();
myNeTree.Name = "myNeTree";
myNeTree.Size = new System.Drawing.Size(95, 350);
//contNe鼠标右键监听事件
myNeTree.MouseDown += new MouseEventHandler(myNeTree_MouseDown);
contNe.Control = myNeTree;
this.NeGroup1.SubItems.AddRange(new DevComponents.DotNetBar.BaseItem[] { radiocont, contNe });
posted on 2008-09-02 15:47
天书 阅读(1339)
评论(0) 编辑 收藏 引用