Ejemplo n.º 1
0
 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);
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 在表格内点右键弹出菜单(菜单自动创建)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void OnShowGridMenu(object sender, DevExpress.XtraGrid.Views.Grid.GridMenuEventArgs e)
        {
            GridView view = sender as GridView;

            if (GridMenuType.Row == e.MenuType || GridMenuType.User == e.MenuType)
            {
                GridViewMenu rowMenu = new GridViewMenu(view);

                CreatePopupMenuItem(rowMenu, "打开配置窗体", Globals.LoadImage("skin16.ico"), menuItemCustomize_Click, false);
                CreatePopupMenuItem(rowMenu, "保存配置", Globals.LoadImage("BtnSaveWindow.png"), menuItemSaveGridConfig_Click, true);
                CreatePopupMenuItem(rowMenu, "还原预设配置", Globals.LoadImage("cslogo16.ico"), menuItemRestoreGridConfig_Click, true);
                CreatePopupMenuItem(rowMenu, "导出资料", Globals.LoadImage("ExportToExcel.png"), menuItemExport_Click, true);
                CreatePopupMenuItem(rowMenu, "复制单元格", Globals.LoadImage("cell.png"), menuItemCopyCellText_Click, true);

                CreateExtraMenuItem(view, rowMenu);//附加其它自定义菜单
                e.Menu = rowMenu;
            }
        }
Ejemplo n.º 3
0
        private void gridViewConfirm_ShowGridMenu(object sender, DevExpress.XtraGrid.Views.Grid.GridMenuEventArgs e)
        {
            GridView gridView = sender as GridView;

            if (gridView != null)
            {
                GridHitInfo hi = gridView.CalcHitInfo(e.Point);
                //如果为新加行,返回
                if (hi.RowHandle == GridControl.NewItemRowHandle)
                {
                    return;
                }
                //GridView上右击不会设置FocusedRow,手动设置
                if (hi.RowHandle >= 0)
                {
                    gridView.FocusedRowHandle = hi.RowHandle;
                }
                //在右击的地方为:数据行,或者 行指示处时,弹出上下文菜单
                if ((hi.HitTest == GridHitTest.RowCell || hi.HitTest == GridHitTest.RowIndicator))
                {
                    //this.popupMenuConfirm.ShowPopup(Control.MousePosition);
                }
            }
        }