DXMenuCheckItem CreateFilterMenuItem(string caption, string stringForTag) { DXMenuCheckItem item = new DXMenuCheckItem(caption, false, null, new EventHandler(OnFilterPanelItemClick)); item.Tag = stringForTag; return(item); }
private DXMenuCheckItem CreateCheckItem(string caption, GridColumn column, Image image, EventHandler eventHandler) { DXMenuCheckItem item = new DXMenuCheckItem(caption, false, image, eventHandler); item.Tag = column; return(item); }
void pivotGridControl1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) { if (e.MenuType == PivotGridMenuType.HeaderSummaries) { int i = 0; while (i < e.Menu.Items.Count) { if (!necessaryItems.Contains(e.Menu.Items[i].Caption)) { e.Menu.Items.RemoveAt(i); } else { i++; } } DXSubMenuItem displayType = new DXSubMenuItem("SummaryDisplayType"); e.Menu.Items.Add(displayType); string curentSummaryDisplayType = Enum.GetName(typeof(PivotSummaryDisplayType), e.Field.SummaryDisplayType); foreach (string str in Enum.GetNames(typeof(PivotSummaryDisplayType))) { DXMenuCheckItem item = new DXMenuCheckItem(str, curentSummaryDisplayType == str); item.Click += new EventHandler(ItemClick); item.Tag = e.Field; displayType.Items.Add(item); } } }
//The handler for the MergingEnabled menu item void OnMergingEnabledClick(object sender, EventArgs e) { DXMenuCheckItem item = sender as DXMenuCheckItem; RowInfo info = item.Tag as RowInfo; info.View.OptionsView.AllowCellMerge = item.Checked; }
public DXMenuItem[] GetNullableEditItem(object obj) { if (obj == null) { return(null); } Type type = obj.GetType(); if (type != typeof(nwind.Products)) { return(null); } DXMenuCheckItem menuItem = new DXMenuCheckItem(); menuItem.Checked = !(obj as Products).Discontinued; if (menuItem.Checked) { menuItem.Caption = "Active Product (Toggle Mode Demo)"; menuItem.Image = Properties.Resources.active; } else { menuItem.Caption = "Inactive Product (Toggle Mode Demo)"; menuItem.Image = Properties.Resources.inactive; } menuItem.Tag = obj; menuItem.Click += ToggleProductStatus; return(new DXMenuItem[] { menuItem }); }
DXMenuCheckItem CreateMenuItemCellMerging(GridView view, int rowHandle) { DXMenuCheckItem checkItem = new DXMenuCheckItem("Cell Merging", view.OptionsView.AllowCellMerge, null, new EventHandler(OnCellMergingClick)); checkItem.Tag = new RowInfo(view, rowHandle); //checkItem.ImageOptions.Image = imageCollection1.Images[1]; return(checkItem); }
//Create a menu item public static DXMenuCheckItem CreateCheckItem(string caption, GridColumn column, FixedStyle style, Color color) { Image image = createImage(color); DXMenuCheckItem item = new DXMenuCheckItem(caption, column.Fixed == style, image, new EventHandler(OnFixedClick)); item.Tag = new MenuInfo(column, style); return(item); }
void AddExportTarget(ExportTarget target) { var exportItem = new DXMenuCheckItem() { Caption = target.ToString(), Tag = target }; menuExport.Items.Add(exportItem); exportItem.Click += exportItem_Click; }
/// <summary> /// Erweiterung der Popup-Menüs /// </summary> private void OnPopupMenuShowing(object sender, PopupMenuShowingEventArgs e) { PivotGridField pivotGridField = e.HitInfo.HeaderField; if (pivotGridField != null) { // PivotSummaryType DXSubMenuItem summaryMenuItem = new DXSubMenuItem { Caption = "Zusammenfassung", BeginGroup = true }; e.Menu.Items.Add(summaryMenuItem); Dictionary <string, PivotSummaryType> summaryTypes = new Dictionary <string, PivotSummaryType> { { "Summe", PivotSummaryType.Sum }, { "Durchschnitt", PivotSummaryType.Average }, { "Anzahl", PivotSummaryType.Count }, { "Minimum", PivotSummaryType.Min }, { "Maximum", PivotSummaryType.Max }, }; foreach (string key in summaryTypes.Keys) { PivotSummaryType summaryType = summaryTypes[key]; DXMenuCheckItem menuItem = new DXMenuCheckItem { Caption = key, Checked = pivotGridField.SummaryType == summaryType }; menuItem.Click += delegate { this.DuplicatePivotGridField(pivotGridField, summaryType, pivotGridField.SummaryDisplayType); }; summaryMenuItem.Items.Add(menuItem); } // PivotSummaryDisplayType DXSubMenuItem summaryDisplayMenuItem = new DXSubMenuItem { Caption = "Anzeigen als" }; e.Menu.Items.Add(summaryDisplayMenuItem); Dictionary <string, PivotSummaryDisplayType> summaryDisplayTypes = new Dictionary <string, PivotSummaryDisplayType> { { "Standard", PivotSummaryDisplayType.Default }, { "Varianz zum Vorgänger (absolut)", PivotSummaryDisplayType.AbsoluteVariation }, { "Varianz zum Vorgänger (prozentual)", PivotSummaryDisplayType.PercentVariation }, { "Prozent vom Gesamt (Spalte)", PivotSummaryDisplayType.PercentOfColumn }, { "Prozent vom Gesamt (Zeile)", PivotSummaryDisplayType.PercentOfRow }, { "Prozent vom Gesamtergebnis (Spalte)", PivotSummaryDisplayType.PercentOfColumnGrandTotal }, { "Prozent vom Gesamtergebnis (Zeile)", PivotSummaryDisplayType.PercentOfRowGrandTotal }, }; foreach (string key in summaryDisplayTypes.Keys) { PivotSummaryDisplayType summaryDisplayType = summaryDisplayTypes[key]; DXMenuCheckItem menuItem = new DXMenuCheckItem { Caption = key, Checked = pivotGridField.SummaryDisplayType == summaryDisplayType }; menuItem.Click += delegate { this.DuplicatePivotGridField(pivotGridField, pivotGridField.SummaryType, summaryDisplayType); }; summaryDisplayMenuItem.Items.Add(menuItem); } } }
// Create a check menu item that triggers the Boolean AllowCellMerge option. DXMenuCheckItem CreateMergingEnabledMenuItem(GridView view, int rowHandle) { var checkItem = new DXMenuCheckItem("&Merging Enabled", view.OptionsView.AllowCellMerge, null, new EventHandler(OnMergingEnabledClick)) { Tag = new RowInfo(view, rowHandle) }; return(checkItem); }
private static DXMenuItem NewDXMenuItem(object sender, PopupMenuShowingEventArgs e, IModelGridViewRuleCustomSummaryCalculate modelGridViewRule) { bool check = e.HitInfo.Column.SummaryItem.SummaryType == SummaryItemType.Custom && Equals(modelGridViewRule, e.HitInfo.Column.SummaryItem.Tag); DXMenuItem menuItem = new DXMenuCheckItem(modelGridViewRule.Caption, check, null, (o, args) => { var item = ((DXMenuItem)sender); var col = ((GridColumn)item.Tag); col.SummaryItem.Tag = modelGridViewRule; col.SummaryItem.SetSummary(SummaryItemType.Custom, string.Empty); }); menuItem.Tag = e.HitInfo.Column; return(menuItem); }
protected DXSubMenuItem CreateSetBookmarkMenu() { DXSubMenuItem menuItem = new DXSubMenuItem(SetBookmarkStr); EventHandler eventHandler = new EventHandler(SetBookmarkMenuItem_Click); for (int i = 0; i < BookmarkCount; i++) { DXMenuCheckItem item = new DXMenuCheckItem(BookmarkStr + i.ToString()); item.Click += eventHandler; item.Tag = i; item.Checked = BookMarks[i] != null; menuItem.Items.Add(item); } return(menuItem); }
void item_Click(object sender, EventArgs e) { DXMenuCheckItem item = sender as DXMenuCheckItem; if (item == null) { return; } CustomSortBySummaryTag tag = item.Tag as CustomSortBySummaryTag; if (tag != null) { SetFieldSortBySummary(tag.Pair.FieldItem, tag.Pair.DataFieldItem, tag.Condition, item.Checked); } }
private void pivotGridControl1_MenuItemClick(object sender, PivotGridMenuItemClickEventArgs e) { DXMenuCheckItem item = sender as DXMenuCheckItem; if (Equals(item, null)) { return; } CustomSortBySummaryTag tag = item.Tag as CustomSortBySummaryTag; if (Equals(tag, null)) { e.Allow = false; } }
void pivotGridControl1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) { if (e.MenuType == PivotGridMenuType.HeaderSummaries) { DXSubMenuItem sdtItem = new DXSubMenuItem(); sdtItem.Caption = "Summary Display Type"; e.Menu.Items.Add(sdtItem); string curentSummaryDisplayType = Enum.GetName(typeof(PivotSummaryDisplayType), e.Field.SummaryDisplayType); foreach (string str in Enum.GetNames(typeof(PivotSummaryDisplayType))) { DXMenuCheckItem item = new DXMenuCheckItem(str, curentSummaryDisplayType == str); item.Click += new EventHandler(ItemClick); item.Tag = e.Field; sdtItem.Items.Add(item); } } }
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); } } }
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); } } }
DXMenuCheckItem CreateCheckItem(string caption, GridColumn column, FixedStyle style, Image image) { DXMenuCheckItem item = new DXMenuCheckItem(caption, column.Fixed == style, image, new EventHandler(OnFixedClick)); item.Tag = new MenuInfo(column, style); if (caption == "Not Fixed") item.BeginGroup = true; return item; }
// Create a check menu item that triggers the Boolean AllowCellMerge option. DXMenuCheckItem CreateMergingEnabledMenuItem(GridView view, int rowHandle) { var checkItem = new DXMenuCheckItem("&Merging Enabled", view.OptionsView.AllowCellMerge, null, new EventHandler(OnMergingEnabledClick)) { Tag = new RowInfo(view, rowHandle) }; return checkItem; }
void pivotGridMaster_ShowMenu(object sender, PivotGridMenuEventArgs e) { if (e.MenuType != PivotGridMenuType.Header) return; DXMenuItem itemTotal = new DXMenuItem(); if (e.Field.TotalsVisibility == PivotTotalsVisibility.None) { itemTotal.Caption = "Hiện total (tổng)"; itemTotal.Tag = PivotTotalsVisibility.AutomaticTotals; } else { itemTotal.Caption = "Ẩn total (tổng)"; itemTotal.Tag = PivotTotalsVisibility.None; } itemTotal.Click += delegate(object senderr, EventArgs re) { e.Field.TotalsVisibility = (PivotTotalsVisibility)itemTotal.Tag; }; DXMenuCheckItem itemNoOrder = new DXMenuCheckItem("Không sắp xếp"); itemNoOrder.Checked = e.Field.SortMode == PivotSortMode.None; DXMenuCheckItem itemAsc = new DXMenuCheckItem("Sắp tăng dần"); itemAsc.Checked = e.Field.SortMode != PivotSortMode.None && e.Field.SortOrder == PivotSortOrder.Ascending; DXMenuCheckItem itemDesc = new DXMenuCheckItem("Sắp giảm dần"); itemDesc.Checked = e.Field.SortMode != PivotSortMode.None && e.Field.SortOrder == PivotSortOrder.Descending; itemNoOrder.CheckedChanged += delegate(object sendere, EventArgs ee) { e.Field.SortMode = PivotSortMode.None; }; itemAsc.CheckedChanged += delegate(object sendere, EventArgs ee) { e.Field.SortMode = PivotSortMode.Value; e.Field.SortOrder = PivotSortOrder.Ascending; }; itemDesc.CheckedChanged += delegate(object sendere, EventArgs ee) { e.Field.SortMode = PivotSortMode.Value; e.Field.SortOrder = PivotSortOrder.Descending; }; DXMenuItem itemSaveLayout = new DXMenuItem("Lưu hình dạng lưới"); DXMenuItem itemDeleteLayout = new DXMenuItem("Xóa hình dạng lưới đã lưu"); itemSaveLayout.Click += delegate(object senderr, EventArgs ee) { try { pivotGridMaster.SaveLayoutToXml(PivotLayoutName); } catch { } }; itemDeleteLayout.Click += delegate(object senderr, EventArgs ee) { try { string f = PivotLayoutName; if (File.Exists(f)) File.Delete(f); pivotGridMaster.BestFit(); } catch { } }; e.Menu.Items[0].BeginGroup = true; e.Menu.Items.Insert(0, itemDeleteLayout); e.Menu.Items.Insert(0, itemSaveLayout); itemSaveLayout.BeginGroup = true; e.Menu.Items.Insert(0, itemNoOrder); e.Menu.Items.Insert(0, itemDesc); e.Menu.Items.Insert(0, itemAsc); itemAsc.BeginGroup = true; e.Menu.Items.Insert(0, itemTotal); }
private void pivotGridControl1_ShowMenu(object sender, DevExpress.XtraPivotGrid.PivotGridMenuEventArgs e) { var pivoFfield = e.Field; #region TODO: temp nousing customize //DXMenuItem itemTotal = new DXMenuItem(); //if (pivoFfield.TotalsVisibility == PivotTotalsVisibility.None) //{ // itemTotal.Caption = "Hiện total (tổng)"; // itemTotal.Tag = PivotTotalsVisibility.AutomaticTotals; //} //else //{ // itemTotal.Caption = "Ẩn total (tổng)"; // itemTotal.Tag = PivotTotalsVisibility.None; //} //itemTotal.Click += delegate(object senderr, EventArgs re) //{ // pivoFfield.TotalsVisibility = (PivotTotalsVisibility)itemTotal.Tag; //}; //DXMenuCheckItem itemNoOrder = new DXMenuCheckItem("Không sắp xếp"); //itemNoOrder.Checked = pivoFfield.SortMode == PivotSortMode.None; //DXMenuCheckItem itemAsc = new DXMenuCheckItem("Sắp tăng dần"); //itemAsc.Checked = pivoFfield.SortMode != PivotSortMode.None && pivoFfield.SortOrder == PivotSortOrder.Ascending; //DXMenuCheckItem itemDesc = new DXMenuCheckItem("Sắp giảm dần"); //itemDesc.Checked = pivoFfield.SortMode != PivotSortMode.None && pivoFfield.SortOrder == PivotSortOrder.Descending; //itemNoOrder.CheckedChanged += delegate(object sendere, EventArgs ee) //{ // pivoFfield.SortMode = PivotSortMode.None; //}; //itemAsc.CheckedChanged += delegate(object sendere, EventArgs ee) //{ // pivoFfield.SortMode = PivotSortMode.Value; // pivoFfield.SortOrder = PivotSortOrder.Ascending; //}; //itemDesc.CheckedChanged += delegate(object sendere, EventArgs ee) //{ // pivoFfield.SortMode = PivotSortMode.Value; // pivoFfield.SortOrder = PivotSortOrder.Descending; //}; #endregion if (pivoFfield == null) { if (e.HitInfo != null && e.HitInfo.ValueInfo != null) { pivoFfield = e.HitInfo.ValueInfo.DataField; } } #region data field Menu if (pivoFfield != null) { #region DataArea Menu if (pivoFfield.Area == PivotArea.DataArea) { var subMenuSummaryTpe = new DXSubMenuItem("Kiểu thống kê"); foreach (PivotSummaryType sumaryType in Enum.GetValues(typeof (PivotSummaryType))) { string caption; switch (sumaryType) { case PivotSummaryType.Sum: caption = "Tổng"; break; case PivotSummaryType.Count: caption = "Đếm"; break; case PivotSummaryType.Average: caption = "Trung bình"; break; case PivotSummaryType.Min: caption = "Nhỏ nhất"; break; case PivotSummaryType.Max: caption = "Lớn nhất"; break; default: continue; } var item = new DXMenuCheckItem(caption) {Tag = sumaryType, Checked = pivoFfield.SummaryType== sumaryType}; item.CheckedChanged += delegate(object senderr, EventArgs ee) { var it = (DXMenuCheckItem) senderr; var type = (PivotSummaryType) it.Tag; pivoFfield.SummaryType = type; ; }; subMenuSummaryTpe.Items.Add(item); } subMenuSummaryTpe.BeginGroup = true; e.Menu.Items.Add(subMenuSummaryTpe); } #endregion } #endregion #region Common menu var itemSaveLayout = new DXMenuItem("Lưu hình dạng lưới"); var itemDeleteLayout = new DXMenuItem("Xóa hình dạng lưới đã lưu"); itemSaveLayout.Click += delegate(object senderr, EventArgs ee) { try { pivotGridControl1.SaveLayoutToXml(PivotLayoutName); } catch { } }; itemDeleteLayout.Click += delegate(object senderr, EventArgs ee) { try { string f = PivotLayoutName; if (File.Exists(f)) File.Delete(f); pivotGridControl1.ResumeLayout(true); pivotGridControl1.BestFit(); } catch { } }; var itemsCount = e.Menu.Items.Count; if (itemsCount > 0) { itemSaveLayout.BeginGroup = true; } e.Menu.Items.Add(itemSaveLayout); e.Menu.Items.Add(itemDeleteLayout); #endregion }
private void gridViewTaiNguyen_ShowGridMenu(object sender, GridMenuEventArgs e) { if (e.MenuType == GridMenuType.Column) { try { GridViewColumnMenu menu = (GridViewColumnMenu)e.Menu; if (menu.Column == null) { e.Allow = false; return; } DXMenuCheckItem menuItemCheckAll = new DXMenuCheckItem("Chọn tất cả", IsShowCheckForCheckAllItem(gridViewTaiNguyen, menu.Column), null, new EventHandler(ProcessCheckAll)); menuItemCheckAll.BeginGroup = true; DXMenuCheckItem menuItemUnCheckAll = new DXMenuCheckItem("Bỏ chọn tất cả", IsShowCheckForUnCheckAllItem(gridViewTaiNguyen, menu.Column), null, new EventHandler(ProcessUnCheckAll)); if (menu.Column.FieldName == "ISCREATE_BIT" || menu.Column.FieldName == "ISREAD_BIT" || menu.Column.FieldName == "ISUPDATE_BIT" || menu.Column.FieldName == "ISDELETE_BIT" || menu.Column.FieldName == "ISFULL_BIT") { menuItemCheckAll.Tag = menu.Column; menuItemUnCheckAll.Tag = menu.Column; menu.Items.Add(menuItemCheckAll); menu.Items.Add(menuItemUnCheckAll); } } catch { HelpMsgBox.ShowErrorMessage( "Chương trình xảy ra lỗi.\nXin vui lòng liên hệ với quản trị hệ thống!"); e.Allow = false; } } }
/// <summary> /// Convert and append the items in a ContextMenuStrip to a DXPopupMenu /// </summary> /// <param name="modelMenu"></param> /// <param name="dxpMenu"></param> void ConvertAndAppendContextMenuStripToDxPopupMenu( ContextMenuStrip modelMenu, DXPopupMenu dxpMenu) { DXMenuItem mi; DXMenuCheckItem cmi; DXSubMenuItem smi; ToolStripMenuItem tsmi, defaultTsmi = new ToolStripMenuItem(); bool separatorSeen = false; int itemCount = modelMenu.Items.Count; int visCnt = 0; for (int mii = 0; mii < itemCount; mii++) { ToolStripItem tsi = modelMenu.Items[mii]; if (!tsi.Available) { continue; } if (tsi is ToolStripSeparator) { if (dxpMenu.Items.Count > 0) // only note if something already in dxpMenu { separatorSeen = true; } continue; } cmi = new DXMenuCheckItem(); if (separatorSeen) { cmi.BeginGroup = true; separatorSeen = false; } cmi.Caption = tsi.Text; cmi.Click += new System.EventHandler(AggregationTypeMenuItem_Click); cmi.Tag = tsi.Tag; // store summary type in tag if (tsi is ToolStripMenuItem) { tsmi = tsi as ToolStripMenuItem; cmi.Checked = tsmi.Checked; if (tsmi.BackColor != defaultTsmi.BackColor) { cmi.Appearance.BackColor = tsi.BackColor; } if (tsmi.Font.Style != 0) { cmi.Appearance.Font = new Font(cmi.Appearance.Font, tsmi.Font.Style); } } cmi.Visible = tsi.Available; if (cmi.Visible) { visCnt++; } dxpMenu.Items.Add(cmi); } return; }