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

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

定义两个不同的popup contentMenu
在mouse_down事件中处理
  1. private void JobTree_MouseDown(object sender, MouseEventArgs e)
  2.  {
  3.  if (e.Button == MouseButtons.Right)
  4.  {
  5.  DevExpress.XtraTreeList.TreeListHitInfo hInfo = this.JobTree.CalcHitInfo(new Point(e.X, e.Y));
  6.  if (hInfo.HitInfoType == DevExpress.XtraTreeList.HitInfoType.Cell) //在单元格上右击了
  7.  {
  8.  if(hInfo.Node.RootNode.Id==hInfo.Node.Id) //说明是根节点 站点
  9.  this.barManager1.SetPopupContextMenu(this.JobTree, this.popupSite);
  10.  else //任务
  11.  this.barManager1.SetPopupContextMenu(this.JobTree, this.popupJob);
  12.  }
  13.  
  14.  }
  15.  }
引用通告地址: 点击获取引用地址
标签: TreeList
评论: 0 | 引用: 0 | 阅读: 1514
发表评论
昵 称: 密 码:
网 址: 邮 箱:
验证码: 验证码图片 选 项:
头 像:
内 容: