private void resourcesTree1_PopupMenuShowing(object sender, DevExpress.XtraTreeList.PopupMenuShowingEventArgs e) { if (e.Menu is TreeListNodeMenu) { e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("Collapse All", resourcesTree1_CollapseAll, DevExpress.Images.ImageResourceCache.Default.GetImage("office2013/actions/squeeze_16x16.png"))); e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("Expand All", resourcesTree1_ExpandAll, DevExpress.Images.ImageResourceCache.Default.GetImage("office2013/actions/stretch_16x16.png"))); } }
private void TreeList1_PopupMenuShowing(object sender, DevExpress.XtraTreeList.PopupMenuShowingEventArgs e) { foreach (DXMenuItem item in e.Menu.Items) { string caption = TreeListLocalizer.Active.GetLocalizedString(TreeListStringId.MenuColumnColumnCustomization); if (item.Caption == caption) { item.Visible = false; } } }
private void trlCRTree_PopupMenuShowing(object sender, DevExpress.XtraTreeList.PopupMenuShowingEventArgs e) { if (e.Menu is TreeListNodeMenu) { trlCRTree.FocusedNode = ((TreeListNodeMenu)e.Menu).Node; object Obj = trlCRTree.GetDataRecordByNode(trlCRTree.FocusedNode); QChangeRequest objCR = (QChangeRequest)Obj; foreach (Type crType in objCR.CompatibleChildren) { e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("Add " + crType.GetDescription(), addHandlers[crType])); } if (modifiers.ContainsKey(objCR.GetType())) { e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem(string.Format("Run {0} modifier.", objCR.GetType().Name), modifiers[objCR.GetType()])); } e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("Delete", trlCRTree_DeleteNode)); if (objCR.GetType() == typeof(QAddCriterioCR)) { e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem(string.Format("Script Criterio"), trlCRTree_ScriptCriterio)); } } }
//右键的弹出窗口 private void treeList2_PopupMenuShowing(object sender, DevExpress.XtraTreeList.PopupMenuShowingEventArgs e) { var menu = e.Menu as DevExpress.XtraTreeList.Menu.TreeListNodeMenu; if (menu == null) { return; } treeList2.FocusedNode = menu.Node; List <FilesTreeNode> data = treeList2.DataSource as List <FilesTreeNode>; var node = data[menu.Node.Id]; if (node.IsDir == true) { if (e.Menu.MenuType == DevExpress.XtraTreeList.Menu.TreeListMenuType.Node) { e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("添加新dwg文档", t2Create_ItemClick)); e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("打开文件夹", t2OpenDid_ItemClick)); } } else { string aLastName = node.Name.Substring(data[menu.Node.Id].Name.LastIndexOf(".") + 1, (data[menu.Node.Id].Name.Length - data[menu.Node.Id].Name.LastIndexOf(".") - 1)); if (e.Menu.MenuType == DevExpress.XtraTreeList.Menu.TreeListMenuType.Node) { if (aLastName == "dwg") { e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("打开", t2Open_ItemClick)); //e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("删除", t2Delete_ItemClick)); } } } }
private void treeList1_PopupMenuShowing(object sender, DevExpress.XtraTreeList.PopupMenuShowingEventArgs e) { //e.Menu.Tag }
//右键弹出菜单 private void treeList1_PopupMenuShowing(object sender, DevExpress.XtraTreeList.PopupMenuShowingEventArgs e) { var menu = e.Menu as DevExpress.XtraTreeList.Menu.TreeListNodeMenu; if (menu == null) { return; } treeList1.FocusedNode = menu.Node; if (treeList1.FocusedNode.Level == 0) { if (e.Menu.MenuType == DevExpress.XtraTreeList.Menu.TreeListMenuType.Node) { if (treeList1.FocusedValue.ToString() == "未分配") { e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("删除", t1Delete_ItemClick)); } else { e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("重命名", t1Edit_ItemClick)); e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("添加工作水平", t1AddChild_ItemClick)); } } } else if (treeList1.FocusedNode.Level == 1) { if (!(getProjectNode(treeList1.FocusedNode) is ProjectTreeLeafNode) && e.Menu.MenuType == DevExpress.XtraTreeList.Menu.TreeListMenuType.Node) { e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("重命名", t1Edit_ItemClick)); e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("添加采区", t1AddChild_ItemClick)); e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("删除", t1Delete_ItemClick)); } } else if (treeList1.FocusedNode.Level == 2) { if (e.Menu.MenuType == DevExpress.XtraTreeList.Menu.TreeListMenuType.Node) { e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("重命名", t1Edit_ItemClick)); e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("添加工作面", t1AddChild_ItemClick)); e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("删除", t1Delete_ItemClick)); } } else if (treeList1.FocusedNode.Level == 3) //工作面节点的菜单 { if (e.Menu.MenuType == DevExpress.XtraTreeList.Menu.TreeListMenuType.Node) { e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("设为当前工作面", t1SetWork_ItemClick)); // e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("隐藏/显示工作面", t1HideWork_ItemClick)); e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("重命名", t1Edit_ItemClick)); e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("删除", t1Delete_ItemClick)); } } else if (treeList1.FocusedNode.Level == 4) //巷道节点的菜单 { if (e.Menu.MenuType == DevExpress.XtraTreeList.Menu.TreeListMenuType.Node) { e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("重命名", t1Edit_ItemClick)); e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("删除", t1Delete_ItemClick)); } } else //应该不会再有下一级节点了 { throw new System.Exception("无效的节点"); } }