void BWSGridControl_ShowGridMenu(object sender, DevExpress.XtraGrid.Views.Grid.GridMenuEventArgs e) { if (e.MenuType == GridMenuType.Column) { GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; if (menu.Column != null) { string sMenuCaption1 = "显示脚注"; if (((GridView)this.MainView).OptionsView.ShowFooter) { sMenuCaption1 = "隐藏脚注"; } string sMenuCaption2 = "显示分组脚注"; if (((GridView)this.MainView).GroupFooterShowMode == DevExpress.XtraGrid.Views.Grid.GroupFooterShowMode.VisibleIfExpanded) { sMenuCaption2 = "隐藏分组脚注"; } DXMenuItem dx5 = new DXMenuItem(sMenuCaption1, ShowFooter); dx5.BeginGroup = true; menu.Items.Add(dx5); DXMenuItem dx6 = new DXMenuItem(sMenuCaption2, ShowGroupFooter); menu.Items.Add(dx6); DXMenuItem dx1 = new DXMenuItem("保存为Excel文件", SaveAsExcel, BWS.ERP.Controls.Properties.Resources.excel.ToBitmap()); dx1.BeginGroup = true; menu.Items.Add(dx1); DXMenuItem dx2 = new DXMenuItem("保存为Word文件", SaveAsWord, BWS.ERP.Controls.Properties.Resources.word.ToBitmap()); menu.Items.Add(dx2); DXMenuItem dx3 = new DXMenuItem("保存为Html文件", SaveAsHtml); menu.Items.Add(dx3); DXMenuItem dx4 = new DXMenuItem("保存为Pdf文件", SaveAsPdf, BWS.ERP.Controls.Properties.Resources.pdf.ToBitmap()); menu.Items.Add(dx4); } } }
void OnPopupMenuShowing(object sender, PopupMenuShowingEventArgs e) { GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; if (menu == null) { return; } menu.Items.Add(new DXMenuItem("Show Sort Dialog", OnItemClick, Resources.SortDialog)); }
private void gridView1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Apps) { GridViewInfo vi = (sender as GridView).GetViewInfo() as GridViewInfo; Rectangle r = vi.ColumnsInfo[(sender as GridView).FocusedColumn].Bounds; Point p = new Point(r.Left, r.Bottom); GridViewColumnMenu menu = new GridViewColumnMenu(sender as GridView); menu.Init((sender as GridView).FocusedColumn); menu.Show(p); } }
/// <summary> /// 显示表头右键菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void att_gridview_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e) { //添加“选择当前列”及"Statistics And Chart" if (e.MenuType == GridMenuType.Column) { DXMenuItem m_selecolumn = new DXMenuItem("选择当前列", att_gridview_GridMenuItemClick); m_selecolumn.Tag = "selectall/" + e.HitInfo.Column.Name + "/" + ((GridView)sender).Name; GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; menu.Items.Add(m_selecolumn); } }
private void tableGridView1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) { if (e.MenuType == GridMenuType.Column) { GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; if (menu.Column == null) { menu.Items.Add(CreateCheckItem("Добавить недостающие записи Пинг-серверов", menu.Column, null, AddPingServers)); menu.Items.Add(CreateCheckItem("Изменение всех значений...", menu.Column, null, ItemsEdit)); } } }
private void tableGridView1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) { if (e.MenuType == GridMenuType.Column) { GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; if (menu.Column == null) { menu.Items.Add(CreateCheckItem("Заполнить остальные поля", menu.Column, null, FillEmptyField)); menu.Items.Add(CreateCheckItem("Найти совпадения адресов", menu.Column, null, FindEqualAddresses)); menu.Items.Add(CreateCheckItem("Сгенерировать IP-адреса", menu.Column, null, GenerateIPAddress)); } } }
/// <summary> /// GridView列头右键菜单栏的选项的设置 /// </summary> private void gvwUser_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e) { if (e.MenuType == DevExpress.XtraGrid.Views.Grid.GridMenuType.Column)//判断是否是列标题的右键菜单 { GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; //menu.Items.RemoveAt(8);//移除右键菜单中的第7个功能,从0开始 //menu.Items.Clear();//清除所有功能 // string strDisp = 自己需要增加的右键信息 // DXMenuItem dxm = new DXMenuItem(); // dxm.Caption = strDisp; // menu.Items.Add(dxm); } }
protected void GridView_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e) { GridViewMenu gridViewMenu = e.Menu as GridViewMenu; if (gridViewMenu == null) { return; } DXMenuItem menuItem = new DXMenuItem("Column Properties"); DXMenuItem gridViewPropertyMenuItem = new DXMenuItem("Grid View Property"); DXMenuItem gridViewSaveLayoutMenuItem = new DXMenuItem("Save Layout"); DXMenuItem gridViewSaveToXlsxItem = new DXMenuItem("Save to Xlsx (WYSIWYG)"); DXMenuItem gridViewSaveToXlsxDataAwareItem = new DXMenuItem("Save to Xlsx (Data-Aware)"); DXMenuItem saveDefaultLayoutMenuItem = new DXMenuItem("Save as Default Layout"); DXMenuItem printPreviewMenuItem = new DXMenuItem("Print Preview"); DXSubMenuItem subMenuItem = new DXSubMenuItem("Layout"); DXSubMenuItem exportSubMenu = new DXSubMenuItem("Export && Print"); if (e.MenuType == GridMenuType.Column) { GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; if (menu.Column != null) { column = e.HitInfo.Column; menuItem.Click += GridForm_GridViewColumnMenu_click; subMenuItem.Items.Add(menuItem); } } subMenuItem.Items.Add(gridViewPropertyMenuItem); subMenuItem.Items.Add(gridViewSaveLayoutMenuItem); exportSubMenu.Items.Add(gridViewSaveToXlsxItem); exportSubMenu.Items.Add(gridViewSaveToXlsxDataAwareItem); exportSubMenu.Items.Add(printPreviewMenuItem); subMenuItem.Items.Add(saveDefaultLayoutMenuItem); gridViewMenu.Items.Add(exportSubMenu); gridViewMenu.Items.Add(subMenuItem); gridViewPropertyMenuItem.Click += GridForm_GridViewPropertyMenuItem_Click; gridViewSaveLayoutMenuItem.Click += GridForm_GridViewSaveLayoutMenuItem_Click; gridViewSaveToXlsxItem.Click += GridForm_GridViewSaveToXlsxItem_Click; gridViewSaveToXlsxDataAwareItem.Click += GridForm_GridViewSaveToXlsxDataAwareItem_Click; printPreviewMenuItem.Click += PrintPreviewMenuItem_Click; saveDefaultLayoutMenuItem.Click += SaveDefaultLayoutMenuItem_Click; if (!IsOwner) { gridViewPropertyMenuItem.Visible = false; menuItem.Visible = false; saveDefaultLayoutMenuItem.Visible = false; } }
private void gridView1_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e) { if (e.MenuType == DevExpress.XtraGrid.Views.Grid.GridMenuType.Column)//判断是否是列标题的右键菜单 { GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; //menu.Items.RemoveAt(6);//移除右键菜单中的第7个功能,从0开始 //menu.Items.Clear();//清除所有功能 DXMenuItem dxm = new DXMenuItem(); dxm.Caption = "字段注册"; dxm.Tag = menu.Column; dxm.Click += new EventHandler(DevIncludeM_Click); menu.Items.Add(dxm); } }
private void sub_gridview_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e) { if (e.MenuType == GridMenuType.Column) { GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; if (menu.Column.AbsoluteIndex == 0) { menu.Items.Clear(); } if (menu.Column.AbsoluteIndex > 2) { DXMenuItem item = new DXMenuItem("Clear data", onClickClearColumn); item.Tag = new MenuColumnInfo(menu.Column); menu.Items.Add(item); } } }
void View_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) { if (!IsShowColumnHeardMenu && e.Menu != null) { e.Menu.Items.Clear(); } if (IsShowConfigButton && e.MenuType == DevExpress.XtraGrid.Views.Grid.GridMenuType.Column) { GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; if (menu != null && ShowSelfConfig) { DXMenuItem customItem = new DXMenuItem("自定义", (o, a) => ShowConfigForm(), XCI.WinUtility.Properties.Resources.GridConfig); customItem.BeginGroup = true; menu.Items.Add(customItem); } } }
private void tableGridView1_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e) { if (e.MenuType == GridMenuType.Column) { GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; //Erasing the default menu items //menu.Items.Clear(); if (menu.Column != null) { //Adding new items if (menu.Column.Caption == "Владелец \"Ежедневник\"") { menu.Items.Add(CreateCheckItem("Сортировать по возрастанию", menu.Column, Properties.Resources.Up, new EventHandler(DateAscendingSort))); menu.Items.Add(CreateCheckItem("Сортировать по убыванию", menu.Column, Properties.Resources.Down, new EventHandler(DateDescendingSort))); } } } }
private void gridView1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { const Keys menuShortcut = Keys.Control | Keys.Shift | Keys.C; // Ctrl+Shift+C if ((e.KeyData & menuShortcut) == menuShortcut) { GridView view = sender as GridView; GridColumn column = view.FocusedColumn; Rectangle rect = GetColumnBounds(column); if (!rect.IsEmpty) // the column is visible { Point pt = rect.Location; pt.Offset(20, 10); GridViewColumnMenu menu = new GridViewColumnMenu(view); menu.Init(column); menu.Show(pt); e.Handled = true; } } }
private void tableGridView1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) { if (e.MenuType == GridMenuType.Column) { GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; //Erasing the default menu items //menu.Items.Clear(); if (menu.Column != null) { if (menu.Column.Caption == "Актив") { menu.Items.Add(CreateCheckItem("Автивировать все", menu.Column, null, ActivateAll)); menu.Items.Add(CreateCheckItem("Деактивировать все", menu.Column, null, DectivateAll)); } } else { menu.Items.Add(CreateCheckItem("Сгенерировать IP-адреса", menu.Column, null, GenerateIPAddress)); menu.Items.Add(CreateCheckItem("Выполнить для всех", menu.Column, null, DoActionAll)); } } }
private void tableGridView1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) { if (e.MenuType == GridMenuType.Column) { GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; //Erasing the default menu items //menu.Items.Clear(); if (menu.Column != null) { //Adding new items menu.Items.Add(CreateCheckItem("Вставить из буфера", menu.Column, TagGenerator.Properties.Resources.Paste, new EventHandler(PasteFromClipboar))); if (menu.Column.Caption == "ArchestrA импорт") { menu.Items.Add(CreateCheckItem("Автивировать все", menu.Column, null, new EventHandler(ActivateAll))); menu.Items.Add(CreateCheckItem("Деактивировать все", menu.Column, null, new EventHandler(DectivateAll))); } } else { menu.Items.Add(CreateCheckItem("Вставить из Simatic PCS", menu.Column, TagGenerator.Properties.Resources.Paste, new EventHandler(PasteFromSimaticPCS))); } } }
public static void AddFontAndColortoPopupMenuShowing(object sender, PopupMenuShowingEventArgs e, GridControl gridcontrol, string FormName) { //nếu sử dụng thì tích hợp save layout. if (e.MenuType == GridMenuType.Column) { GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; //menu.Items.Clear(); if (menu.Column != null) { var renameCap = new DXMenuCheckItem("Đổi tên cột"); renameCap.ImageOptions.SvgImage = Properties.Resource.editnames; renameCap.Click += (ss, ee) => { var caption = menu.Column.Caption; frmRenameCaption frm = new frmRenameCaption(caption); if (frm.ShowDialog() == DialogResult.OK) { menu.Column.Caption = frm.Caption; } }; menu.Items.Add(renameCap); var fixLeft = new DXMenuCheckItem("Ghim Trái"); fixLeft.ImageOptions.SvgImage = Properties.Resource.showlegendinsideverticalcenterleft; menu.Items.Add(fixLeft); fixLeft.Click += (ss, ee) => { menu.Column.Fixed = FixedStyle.Left; }; var fixRight = new DXMenuCheckItem("Ghim Phải"); fixRight.ImageOptions.SvgImage = Properties.Resource.showlegendinsideverticalcenterright; menu.Items.Add(fixRight); fixRight.Click += (ss, ee) => { menu.Column.Fixed = FixedStyle.Right; }; var unFix = new DXMenuCheckItem("Xóa Ghim"); unFix.ImageOptions.SvgImage = Properties.Resource.manual; unFix.Enabled = menu.Column.Fixed != FixedStyle.None; menu.Items.Add(unFix); unFix.Click += (ss, ee) => { menu.Column.Fixed = FixedStyle.None; }; // font chữ DXMenuCheckItem font = new DXMenuCheckItem("Fonts", true); font.ImageOptions.SvgImage = Properties.Resource.changetextcase; font.Click += new EventHandler(OnFixedClick); font.Tag = new MenuInfo(menu.Column, FixedStyle.None); menu.Items.Add(font); // Màu nền DXSubMenuItem sItem = new DXSubMenuItem("Màu Nền"); sItem.ImageOptions.SvgImage = Properties.Resource.pagecolor; Color mauhong = ColorTranslator.FromHtml("#FFC2BE"); Color mauxanh = ColorTranslator.FromHtml("#A8D5FF"); Color xanhduong = ColorTranslator.FromHtml("#C1F49C"); Color mauvang = ColorTranslator.FromHtml("#FEF7A5"); Color mautim = ColorTranslator.FromHtml("#E0CFE9"); Color xanhlam = ColorTranslator.FromHtml("#8DE9DF"); Color mautrang = ColorTranslator.FromHtml("#FFFFFF"); Color mauden = ColorTranslator.FromHtml("#000000"); sItem.Items.Add(CreateCheckItem("Color White", menu.Column, FixedStyle.None, mautrang)); sItem.Items.Add(CreateCheckItem("Color Black", menu.Column, FixedStyle.None, mauden)); sItem.Items.Add(CreateCheckItem("Color Pink", menu.Column, FixedStyle.None, mauhong)); sItem.Items.Add(CreateCheckItem("Color Blue", menu.Column, FixedStyle.None, mauxanh)); sItem.Items.Add(CreateCheckItem("Color Green", menu.Column, FixedStyle.None, xanhduong)); sItem.Items.Add(CreateCheckItem("Color Yellow", menu.Column, FixedStyle.None, mauvang)); sItem.Items.Add(CreateCheckItem("Color Purple", menu.Column, FixedStyle.None, mautim)); sItem.Items.Add(CreateCheckItem("Color Cyan", menu.Column, FixedStyle.None, xanhlam)); sItem.Items.Add(CreateCheckItem("Color Customize...", menu.Column, FixedStyle.None, Color.Transparent)); menu.Items.Add(sItem); // màu chữ var mauchu = new DXSubMenuItem("Màu Chữ"); mauchu.ImageOptions.SvgImage = Properties.Resource.floatingobjectfillcolor; Color Red = Color.Red; Color pink = ColorTranslator.FromHtml("#E91E63"); Color purple = ColorTranslator.FromHtml("#9C27B0"); Color DeepPurple = ColorTranslator.FromHtml("#673AB7"); Color Indigo = ColorTranslator.FromHtml("#E0CFE9"); Color blue = ColorTranslator.FromHtml("#3F51B5"); Color cyan = ColorTranslator.FromHtml("#00BCD4"); Color Teal = ColorTranslator.FromHtml("#009688"); Color green = ColorTranslator.FromHtml("#4CAF50"); Color Lime = ColorTranslator.FromHtml("#CDDC39"); Color Amber = ColorTranslator.FromHtml("#FFC107"); Color Orange = ColorTranslator.FromHtml("#FF9800"); Color depOrange = ColorTranslator.FromHtml("#FF5722"); Color brown = ColorTranslator.FromHtml("#795548"); Color grey = ColorTranslator.FromHtml("#9E9E9E"); Color BlueGrey = ColorTranslator.FromHtml("#607D8B"); Color Black = ColorTranslator.FromHtml("#000000"); Color White = ColorTranslator.FromHtml("#FFFFFF"); mauchu.Items.Add(CreateCheckItem("Black", menu.Column, FixedStyle.None, Black)); mauchu.Items.Add(CreateCheckItem("White", menu.Column, FixedStyle.None, White)); mauchu.Items.Add(CreateCheckItem("Pink", menu.Column, FixedStyle.None, pink)); mauchu.Items.Add(CreateCheckItem("Purple", menu.Column, FixedStyle.None, purple)); mauchu.Items.Add(CreateCheckItem("Deep Purple", menu.Column, FixedStyle.None, DeepPurple)); mauchu.Items.Add(CreateCheckItem("Indigo", menu.Column, FixedStyle.None, Indigo)); // mauchu.Items.Add(CreateCheckItem("Red", menu.Column, FixedStyle.None, Red)); mauchu.Items.Add(CreateCheckItem("Blue", menu.Column, FixedStyle.None, blue)); mauchu.Items.Add(CreateCheckItem("Cyan", menu.Column, FixedStyle.None, cyan)); mauchu.Items.Add(CreateCheckItem("Teal", menu.Column, FixedStyle.None, Teal)); mauchu.Items.Add(CreateCheckItem("Green", menu.Column, FixedStyle.None, green)); mauchu.Items.Add(CreateCheckItem("Lime", menu.Column, FixedStyle.None, Lime)); mauchu.Items.Add(CreateCheckItem("Amber", menu.Column, FixedStyle.None, Amber)); mauchu.Items.Add(CreateCheckItem("Orange", menu.Column, FixedStyle.None, Orange)); mauchu.Items.Add(CreateCheckItem("Deep Orange", menu.Column, FixedStyle.None, depOrange)); mauchu.Items.Add(CreateCheckItem("Brown", menu.Column, FixedStyle.None, brown)); mauchu.Items.Add(CreateCheckItem("Grey", menu.Column, FixedStyle.None, grey)); mauchu.Items.Add(CreateCheckItem("Blue Grey", menu.Column, FixedStyle.None, BlueGrey)); mauchu.Items.Add(CreateCheckItem("ForeColor Customize...", menu.Column, FixedStyle.None, Color.Transparent)); menu.Items.Add(mauchu); DXMenuCheckItem save_layout = new DXMenuCheckItem("Lưu Kiểu", true); save_layout.ImageOptions.SvgImage = Properties.Resource.saveas; save_layout.CheckedChanged += (ss, ee) => { var path = TEMP_PATH + "\\" + FormName + "\\" + gridcontrol.Name + "\\custom_layout.xml"; gridcontrol.MainView.SaveLayoutToXml(path, OptionsLayoutBase.FullLayout); //FrmMain.Instance.ShowMessageInfo("Đã lưu cấu hình layout."); }; DXMenuCheckItem reset_layout = new DXMenuCheckItem("Kiểu mặc định", true); reset_layout.CheckedChanged += (ss, ee) => { var path = TEMP_PATH + "\\" + FormName + "\\" + gridcontrol.Name + "\\default_layout.xml"; var path_custom = TEMP_PATH + "\\" + FormName + "\\" + gridcontrol.Name + "\\custom_layout.xml"; if (File.Exists(path)) { gridcontrol.MainView.RestoreLayoutFromXml(path, OptionsLayoutBase.FullLayout); //FrmMain.Instance.ShowMessageInfo("Reset layout thành công."); } if (File.Exists(path_custom)) { File.Delete(path_custom); } }; reset_layout.ImageOptions.SvgImage = Properties.Resource.bo_audit_changehistory; menu.Items.Add(save_layout); menu.Items.Add(reset_layout); } } }
public static void AddFontAndColortoPopupMenuShowing(object sender, PopupMenuShowingEventArgs e, GridControl gridcontrol, string FormName) { //nếu sử dụng thì tích hợp save layout. if (e.MenuType == GridMenuType.Column) { GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; //menu.Items.Clear(); if (menu.Column != null) { // font chữ DXMenuCheckItem font = new DXMenuCheckItem("Fonts", true, Properties.Resources.font_16, new EventHandler(OnFixedClick)); font.Tag = new MenuInfo(menu.Column, FixedStyle.None); menu.Items.Add(font); // Màu nền DXSubMenuItem sItem = new DXSubMenuItem("Back Ground"); sItem.ImageOptions.Image = Properties.Resources.background; Color mauhong = ColorTranslator.FromHtml("#FFC2BE"); Color mauxanh = ColorTranslator.FromHtml("#A8D5FF"); Color xanhduong = ColorTranslator.FromHtml("#C1F49C"); Color mauvang = ColorTranslator.FromHtml("#FEF7A5"); Color mautim = ColorTranslator.FromHtml("#E0CFE9"); Color xanhlam = ColorTranslator.FromHtml("#8DE9DF"); Color mautrang = ColorTranslator.FromHtml("#FFFFFF"); Color mauden = ColorTranslator.FromHtml("#000000"); sItem.Items.Add(CreateCheckItem("Color White", menu.Column, FixedStyle.None, mautrang)); sItem.Items.Add(CreateCheckItem("Color Black", menu.Column, FixedStyle.None, mauden)); sItem.Items.Add(CreateCheckItem("Color Pink", menu.Column, FixedStyle.None, mauhong)); sItem.Items.Add(CreateCheckItem("Color Blue", menu.Column, FixedStyle.None, mauxanh)); sItem.Items.Add(CreateCheckItem("Color Green", menu.Column, FixedStyle.None, xanhduong)); sItem.Items.Add(CreateCheckItem("Color Yellow", menu.Column, FixedStyle.None, mauvang)); sItem.Items.Add(CreateCheckItem("Color Purple", menu.Column, FixedStyle.None, mautim)); sItem.Items.Add(CreateCheckItem("Color Cyan", menu.Column, FixedStyle.None, xanhlam)); sItem.Items.Add(CreateCheckItem("Color Customize...", menu.Column, FixedStyle.None, Color.Transparent)); menu.Items.Add(sItem); // màu chữ var mauchu = new DXSubMenuItem("Fore Color"); mauchu.ImageOptions.Image = Properties.Resources.forcolor; Color Red = Color.Red; Color pink = ColorTranslator.FromHtml("#E91E63"); Color purple = ColorTranslator.FromHtml("#9C27B0"); Color DeepPurple = ColorTranslator.FromHtml("#673AB7"); Color Indigo = ColorTranslator.FromHtml("#E0CFE9"); Color blue = ColorTranslator.FromHtml("#3F51B5"); Color cyan = ColorTranslator.FromHtml("#00BCD4"); Color Teal = ColorTranslator.FromHtml("#009688"); Color green = ColorTranslator.FromHtml("#4CAF50"); Color Lime = ColorTranslator.FromHtml("#CDDC39"); Color Amber = ColorTranslator.FromHtml("#FFC107"); Color Orange = ColorTranslator.FromHtml("#FF9800"); Color depOrange = ColorTranslator.FromHtml("#FF5722"); Color brown = ColorTranslator.FromHtml("#795548"); Color grey = ColorTranslator.FromHtml("#9E9E9E"); Color BlueGrey = ColorTranslator.FromHtml("#607D8B"); Color Black = ColorTranslator.FromHtml("#000000"); Color White = ColorTranslator.FromHtml("#FFFFFF"); mauchu.Items.Add(CreateCheckItem("Black", menu.Column, FixedStyle.None, Black)); mauchu.Items.Add(CreateCheckItem("White", menu.Column, FixedStyle.None, White)); mauchu.Items.Add(CreateCheckItem("Pink", menu.Column, FixedStyle.None, pink)); mauchu.Items.Add(CreateCheckItem("Purple", menu.Column, FixedStyle.None, purple)); mauchu.Items.Add(CreateCheckItem("Deep Purple", menu.Column, FixedStyle.None, DeepPurple)); mauchu.Items.Add(CreateCheckItem("Indigo", menu.Column, FixedStyle.None, Indigo)); // mauchu.Items.Add(CreateCheckItem("Red", menu.Column, FixedStyle.None, Red)); mauchu.Items.Add(CreateCheckItem("Blue", menu.Column, FixedStyle.None, blue)); mauchu.Items.Add(CreateCheckItem("Cyan", menu.Column, FixedStyle.None, cyan)); mauchu.Items.Add(CreateCheckItem("Teal", menu.Column, FixedStyle.None, Teal)); mauchu.Items.Add(CreateCheckItem("Green", menu.Column, FixedStyle.None, green)); mauchu.Items.Add(CreateCheckItem("Lime", menu.Column, FixedStyle.None, Lime)); mauchu.Items.Add(CreateCheckItem("Amber", menu.Column, FixedStyle.None, Amber)); mauchu.Items.Add(CreateCheckItem("Orange", menu.Column, FixedStyle.None, Orange)); mauchu.Items.Add(CreateCheckItem("Deep Orange", menu.Column, FixedStyle.None, depOrange)); mauchu.Items.Add(CreateCheckItem("Brown", menu.Column, FixedStyle.None, brown)); mauchu.Items.Add(CreateCheckItem("Grey", menu.Column, FixedStyle.None, grey)); mauchu.Items.Add(CreateCheckItem("Blue Grey", menu.Column, FixedStyle.None, BlueGrey)); mauchu.Items.Add(CreateCheckItem("ForeColor Customize...", menu.Column, FixedStyle.None, Color.Transparent)); menu.Items.Add(mauchu); DXMenuCheckItem save_layout = new DXMenuCheckItem("Save Layout", true); save_layout.ImageOptions.Image = Properties.Resources.save; save_layout.CheckedChanged += (ss, ee) => { var path = TEMP_PATH + "\\" + FormName + "\\" + gridcontrol.Name + "\\custom_layout.xml"; gridcontrol.MainView.SaveLayoutToXml(path, OptionsLayoutBase.FullLayout); //FrmMain.Instance.ShowMessageInfo("Đã lưu cấu hình layout."); }; DXMenuCheckItem reset_layout = new DXMenuCheckItem("Reset Layout", true); reset_layout.CheckedChanged += (ss, ee) => { var path = TEMP_PATH + "\\" + FormName + "\\" + gridcontrol.Name + "\\default_layout.xml"; var path_custom = TEMP_PATH + "\\" + FormName + "\\" + gridcontrol.Name + "\\custom_layout.xml"; if (File.Exists(path)) { gridcontrol.MainView.RestoreLayoutFromXml(path, OptionsLayoutBase.FullLayout); //FrmMain.Instance.ShowMessageInfo("Reset layout thành công."); } if (File.Exists(path_custom)) { File.Delete(path_custom); } }; reset_layout.ImageOptions.Image = Properties.Resources.reset_16x16; menu.Items.Add(save_layout); menu.Items.Add(reset_layout); } } }
void vw_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e) { if (e.MenuType == GridMenuType.Column) { GridViewColumnMenu menu = e.Menu as GridViewColumnMenu; if (menu != null) { foreach (DevExpress.Utils.Menu.DXMenuItem item in menu.Items) { //禁止显示隐藏列 if (item.Caption == GridLocalizer.Active.GetLocalizedString(GridStringId.MenuColumnColumnCustomization)) { item.Enabled = false; } //禁止GridStringId.MenuColumnGroup=根据此列分组 if (item.Caption == GridLocalizer.Active.GetLocalizedString(GridStringId.MenuColumnGroup)) { item.Enabled = false; } //禁止GridStringId.MenuColumnGroupBox=分组依据框 if (item.Caption == GridLocalizer.Active.GetLocalizedString(GridStringId.MenuColumnGroupBox)) { item.Enabled = false; } //禁止GridStringId.MenuColumnRemoveColumn=移除列 if (item.Caption == GridLocalizer.Active.GetLocalizedString(GridStringId.MenuColumnRemoveColumn)) { item.Enabled = false; } //禁止Show Group By Box if (0 == string.Compare( item.Caption, GridLocalizer.Active.GetLocalizedString(GridStringId.MenuGroupPanelShow), true )) { item.Visible = item.Enabled = false; } //Show Auto Filter Row if (0 == string.Compare(item.Caption, GridLocalizer.Active.GetLocalizedString(GridStringId.MenuColumnAutoFilterRowShow), true)) { item.Caption = "显示查询行"; } if (0 == string.Compare(item.Caption, GridLocalizer.Active.GetLocalizedString(GridStringId.MenuColumnAutoFilterRowHide), true)) { item.Caption = "隐藏查询行"; } //禁止Show Find Panel if (0 == string.Compare(item.Caption, GridLocalizer.Active.GetLocalizedString(GridStringId.MenuColumnFindFilterShow), true)) { item.Visible = item.Enabled = false; } } } } }