Esempio n. 1
0
        private void gvRolls_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e)
        {
            if (e.MenuType == DevExpress.XtraGrid.Views.Grid.GridMenuType.Row)
            {
                if (e.HitInfo.InRow && e.HitInfo.RowInfo != null)
                {
                    DevExpress.XtraGrid.Views.Grid.GridView gv = (DevExpress.XtraGrid.Views.Grid.GridView)sender;

                    dynamic obj = null;
                    object  itm = gv.GetRow(gv.FocusedRowHandle);



                    DevExpress.XtraGrid.Menu.GridViewMenu menu = e.Menu as DevExpress.XtraGrid.Menu.GridViewMenu;
                    menu.Items.Clear();

                    DevExpress.Utils.Menu.DXMenuItem mgr = new DevExpress.Utils.Menu.DXMenuItem();
                    mgr.Caption = $"Delete";
                    mgr.Click  += delegate(object o, EventArgs args)
                    {
                        gv.DeleteSelectedRows();
                        ReCalcs();
                    };
                    menu.Items.Add(mgr);
                }
            }
        }
Esempio n. 2
0
        private void grv_ShowGridMenu(object sender, GridMenuEventArgs e)
        {
            if (e.MenuType != DevExpress.XtraGrid.Views.Grid.GridMenuType.Column)
            {
                return;
            }
            try
            {
                DevExpress.XtraGrid.Menu.GridViewMenu headerMenu = (DevExpress.XtraGrid.Menu.GridViewMenu)e.Menu;
                if (headerMenu.Items.Count > 11)
                {
                    return;
                }

                DevExpress.Utils.Menu.DXMenuItem menuItem      = new DevExpress.Utils.Menu.DXMenuItem("Reset Layout Grid", new EventHandler(MyMenuItem));
                DevExpress.Utils.Menu.DXMenuItem menuSave      = new DevExpress.Utils.Menu.DXMenuItem("Save Layout Grid", new EventHandler(MenuSave));
                DevExpress.Utils.Menu.DXMenuItem menuItemClear = new DevExpress.Utils.Menu.DXMenuItem("Clear Layout Grid", new EventHandler(MenuClear));
                menuItem.BeginGroup = true;
                menuItem.Tag        = e.Menu;
                menuItem.BeginGroup = true;
                menuItemClear.Tag   = e.Menu;
                menuSave.Tag        = e.Menu;

                headerMenu.Items.Add(menuItem);
                headerMenu.Items.Add(menuItemClear);
                headerMenu.Items.Add(menuSave);
            }
            catch
            {
            }
        }
Esempio n. 3
0
        private void DrillGrid_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e)
        {
            DevExpress.XtraGrid.Menu.GridViewMenu gridViewMenu = e.Menu;
            if (gridViewMenu == null)
            {
                return;
            }
            DXMenuItem gridViewSaveToXlsxItem          = new DXMenuItem("Save to Xlsx (WYSIWYG)");
            DXMenuItem gridViewSaveToXlsxDataAwareItem = new DXMenuItem("Save to Xlsx (Data-Aware)");

            gridViewMenu.Items.Add(gridViewSaveToXlsxItem);
            gridViewMenu.Items.Add(gridViewSaveToXlsxDataAwareItem);
            gridViewSaveToXlsxItem.Click          += DrillGrid_GridViewSaveToXlsxItem_Click;
            gridViewSaveToXlsxDataAwareItem.Click += DrillGrid_GridViewSaveToXlsxDataAwareItem_Click;
        }
Esempio n. 4
0
        private void gridView1_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e)
        {
            if (e.MenuType == DevExpress.XtraGrid.Views.Grid.GridMenuType.Row)
            {
                if (e.HitInfo.InRow && e.HitInfo.RowInfo != null)
                {
                    DevExpress.XtraGrid.Views.Grid.GridView gv = (DevExpress.XtraGrid.Views.Grid.GridView)sender;

                    dynamic obj = null;
                    object  itm = gv.GetRow(gv.FocusedRowHandle);

                    string        displaytext = String.Empty;
                    List <string> columns     = new List <string>();
                    DataRow       drSelected  = null;
                    if (itm != null)
                    {
                        Int64 id = 0;
                        if (itm is System.Data.DataRowView)
                        {
                            drSelected = ((System.Data.DataRowView)itm).Row;
                            id         = (Int64)((System.Data.DataRowView)itm).Row[0];
                            foreach (System.Text.RegularExpressions.Match match in System.Text.RegularExpressions.Regex.Matches(this.ListOfType.DisplayText, @"(?<!\w)@\w+"))
                            {
                                columns.Add(match.Value);
                            }
                            displaytext = this.ListOfType.DisplayText;
                            columns.ForEach(c => displaytext = displaytext.Replace(c, drSelected[c.Replace("@", "")].ToString()));
                        }
                        else
                        {
                            obj = itm;
                        }
                    }


                    DevExpress.XtraGrid.Menu.GridViewMenu menu = e.Menu as DevExpress.XtraGrid.Menu.GridViewMenu;
                    menu.Items.Clear();

                    DevExpress.Utils.Menu.DXMenuItem mgr = new DevExpress.Utils.Menu.DXMenuItem();
                    mgr.Caption = $"Edit {displaytext}";
                    mgr.Click  += delegate(object o, EventArgs args)
                    {
                        LoadEntityForm((DevExpress.XtraGrid.Views.Grid.GridView)sender);
                    };
                    menu.Items.Add(mgr);

                    DataTable dt = new DataTable();
                    MyApp.CTech.ExecSQL($"SELECT * FROM  MenuItemContextMenu WHERE Menuitem = {this.ListOfType.ID}", ref dt);
                    foreach (DataRow dr in dt.Rows)
                    {
                        DevExpress.Utils.Menu.DXMenuItem mnu = new DevExpress.Utils.Menu.DXMenuItem();
                        mnu.Caption = dr.Field <string>("DisplayText");
                        mnu.Click  += delegate(object o, EventArgs args)
                        {
                            System.Reflection.MethodInfo theMethod = this.ListOfType.RuntimeObjectType.GetMethod(dr.Field <string>("Event"));
                            if (theMethod != null)
                            {
                                var x = theMethod.Invoke(obj, new object[] { });
                                this.ReloadDataSource();
                            }
                        };
                        menu.Items.Add(mnu);
                    }
                    mgr            = new DevExpress.Utils.Menu.DXMenuItem();
                    mgr.BeginGroup = true;
                    mgr.Caption    = $"Excel(xlsx) Export";
                    mgr.Click     += delegate(object o, EventArgs args)
                    {
                        SaveFileDialog dlg = new SaveFileDialog();
                        dlg.Filter     = "*.xlsx|*.xlsx";
                        dlg.DefaultExt = ".xlsx";
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            cntrlSearch1.gridView1.ExportToXlsx(dlg.FileName);
                            System.Diagnostics.Process.Start(dlg.FileName);
                        }
                    };
                    menu.Items.Add(mgr);
                }
            }
        }