posts - 124,  comments - 29,  trackbacks - 0

        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)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理



<2008年9月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(5)

随笔档案

文章分类

文章档案

好友的Bolg

搜索

  •  

最新评论

阅读排行榜

评论排行榜