火车头的Blog!

火车,沉稳、快速的前进

给TreeList的根和子节点弹出不同的右键菜单

好象没几个人用dev的treelist,好早就想实现这个效果,经过一个多小时的摸索,终于找到了实现方法

定义两个不同的popup contentMenu
在mouse_down事件中处理
private void JobTree_MouseDown(object sender, MouseEventArgs e)
        
{
            
if (e.Button == MouseButtons.Right)
            
{
                DevExpress.XtraTreeList.TreeListHitInfo hInfo 
= this.JobTree.CalcHitInfo(new Point(e.X, e.Y));
                
if (hInfo.HitInfoType == DevExpress.XtraTreeList.HitInfoType.Cell) //在单元格上右击了
                {
                    
if(hInfo.Node.RootNode.Id==hInfo.Node.Id) //说明是根节点 站点
                        this.barManager1.SetPopupContextMenu(this.JobTree, this.popupSite);
                    
else  //任务
                        this.barManager1.SetPopupContextMenu(this.JobTree, this.popupJob);
                }

                
            }

        }


posted on 2006-10-18 00:02  _火车头_  阅读(1459)  评论(2编辑  收藏  举报

导航