DevExpress右键菜单使用
添加BarManager和popupMenu组建:
设置popupMenu组件的Manager属性:
右键点击popupMenu主键,点击Customize选项添加菜单:
然后便可添加到鼠标事件中,此处以TreeList为例:
private void treeList1_MouseUp(object sender, MouseEventArgs e) { TreeList tree = sender as TreeList; if (e.Button == MouseButtons.Right && ModifierKeys == Keys.None && treeList1.State == TreeListState.Regular) { Point p = new Point(Cursor.Position.X, Cursor.Position.Y); TreeListHitInfo hitInfo = tree.CalcHitInfo(e.Location); if (hitInfo.HitInfoType == HitInfoType.Cell) { tree.SetFocusedNode(hitInfo.Node); } if (tree.FocusedNode != null) { popupMenu1.ShowPopup(p); } } }