Beispiel #1
0
        void gridView1_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e)
        {
            if (e.MenuType != DevExpress.XtraGrid.Views.Grid.GridMenuType.Summary)
            {
                return;
            }

            DevExpress.XtraGrid.Menu.GridViewFooterMenu footerMenu = e.Menu as DevExpress.XtraGrid.Menu.GridViewFooterMenu;
            bool check = e.HitInfo.Column.SummaryItem.SummaryType == DevExpress.Data.SummaryItemType.Custom && Equals("Count", e.HitInfo.Column.SummaryItem.Tag);

            DevExpress.Utils.Menu.DXMenuItem menuItem = new DevExpress.Utils.Menu.DXMenuCheckItem("Active Count", check, null, new EventHandler(MyMenuItem));
            menuItem.Tag = e.HitInfo.Column;
            foreach (DevExpress.Utils.Menu.DXMenuItem item in footerMenu.Items)
            {
                item.Enabled = true;
            }
            footerMenu.Items.Add(menuItem);
        }
Beispiel #2
0
        private void GridView_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e)
        {
            if (e.MenuType == DevExpress.XtraGrid.Views.Grid.GridMenuType.Column)
            {
                e.Menu.Items.Clear();
                DevExpress.XtraGrid.Views.BandedGrid.ViewInfo.BandedGridHitInfo bandinfo = e.HitInfo as DevExpress.XtraGrid.Views.BandedGrid.ViewInfo.BandedGridHitInfo;
                if (bandinfo.Band != null && bandinfo.Band.Columns.Count == 1)
                {
                    BandedGridColumn Column = bandinfo.Band.Columns[0];

                    DevExpress.Utils.Menu.DXMenuCheckItem itemSortAZ = new DevExpress.Utils.Menu.DXMenuCheckItem();
                    itemSortAZ.Caption = "正序";
                    itemSortAZ.Image   = DevExpress.XtraGrid.Menu.GridMenuImages.Column.Images[1];
                    itemSortAZ.Click  += new EventHandler(itemSortAZ_Click);
                    itemSortAZ.Tag     = bandinfo.Band.Columns[0];
                    if (Column.SortOrder == DevExpress.Data.ColumnSortOrder.Ascending)
                    {
                        itemSortAZ.Checked = true;
                    }
                    e.Menu.Items.Add(itemSortAZ);

                    DevExpress.Utils.Menu.DXMenuCheckItem itemSortZA = new DevExpress.Utils.Menu.DXMenuCheckItem();
                    itemSortZA.Caption = "逆序";
                    itemSortZA.Image   = DevExpress.XtraGrid.Menu.GridMenuImages.Column.Images[2];
                    itemSortZA.Click  += new EventHandler(itemSortZA_Click);
                    itemSortZA.Tag     = bandinfo.Band.Columns[0];
                    if (Column.SortOrder == DevExpress.Data.ColumnSortOrder.Descending)
                    {
                        itemSortZA.Checked = true;
                    }
                    e.Menu.Items.Add(itemSortZA);

                    DevExpress.Utils.Menu.DXMenuItem itemSortCancel = new DevExpress.Utils.Menu.DXMenuItem();
                    itemSortCancel.Caption = "取消排序";
                    itemSortCancel.Tag     = bandinfo.Band.Columns[0];
                    itemSortCancel.Click  += new EventHandler(itemSortCancel_Click);
                    e.Menu.Items.Add(itemSortCancel);

                    //有列合并时禁用排序
                    if (bandinfo.Band.HasChildren)
                    {
                        itemSortAZ.Enabled     = false;
                        itemSortZA.Enabled     = false;
                        itemSortCancel.Enabled = false;
                    }
                    else
                    {
                        itemSortAZ.Enabled     = true;
                        itemSortZA.Enabled     = true;
                        itemSortCancel.Enabled = true;
                    }


                    DevExpress.Utils.Menu.DXMenuItem splitSort = new DevExpress.Utils.Menu.DXMenuItem();
                    splitSort.Caption = "-";
                    e.Menu.Items.Add(splitSort);

                    if (GridView.GroupedColumns.Contains(Column))
                    {
                        DevExpress.Utils.Menu.DXMenuItem itemUnGroup = new DevExpress.Utils.Menu.DXMenuItem();
                        itemUnGroup.Caption = "取消分组";
                        itemUnGroup.Image   = DevExpress.XtraGrid.Menu.GridMenuImages.GroupPanel.Images[2];
                        itemUnGroup.Tag     = bandinfo.Band.Columns[0];
                        itemUnGroup.Click  += new EventHandler(itemUnGroup_Click);
                        e.Menu.Items.Add(itemUnGroup);
                    }
                    else
                    {
                        DevExpress.Utils.Menu.DXMenuItem itemGroup = new DevExpress.Utils.Menu.DXMenuItem();
                        itemGroup.Caption = "分组";
                        itemGroup.Image   = DevExpress.XtraGrid.Menu.GridMenuImages.Column.Images[3];
                        itemGroup.Tag     = bandinfo.Band.Columns[0];
                        itemGroup.Click  += new EventHandler(itemGroup_Click);
                        e.Menu.Items.Add(itemGroup);
                    }

                    DevExpress.Utils.Menu.DXMenuItem itemAgvColWidth = new DevExpress.Utils.Menu.DXMenuItem();
                    itemAgvColWidth.Caption = "最佳列宽效果";
                    itemAgvColWidth.Image   = DevExpress.XtraGrid.Menu.GridMenuImages.Column.Images[6];
                    itemAgvColWidth.Tag     = bandinfo.Band.Columns[0];
                    itemAgvColWidth.Click  += new EventHandler(itemAgvColWidth_Click);
                    e.Menu.Items.Add(itemAgvColWidth);


                    DevExpress.Utils.Menu.DXMenuItem splitGroup = new DevExpress.Utils.Menu.DXMenuItem();
                    splitGroup.Caption = "-";
                    e.Menu.Items.Add(splitGroup);

                    if (GridView.OptionsView.ShowAutoFilterRow)
                    {
                        DevExpress.Utils.Menu.DXMenuItem itemFilerEditor = new DevExpress.Utils.Menu.DXMenuItem();
                        itemFilerEditor.Caption = "取消过滤行";
                        itemFilerEditor.Image   = DevExpress.XtraGrid.Menu.GridMenuImages.Column.Images[7];
                        itemFilerEditor.Tag     = bandinfo.Band.Columns[0];
                        itemFilerEditor.Click  += new EventHandler(itemFilerEditor_Click);
                        e.Menu.Items.Add(itemFilerEditor);
                    }
                    else
                    {
                        DevExpress.Utils.Menu.DXMenuItem itemFilerEditor = new DevExpress.Utils.Menu.DXMenuItem();
                        itemFilerEditor.Caption = "自动过滤行";
                        itemFilerEditor.Image   = DevExpress.XtraGrid.Menu.GridMenuImages.Column.Images[8];
                        itemFilerEditor.Tag     = bandinfo.Band.Columns[0];
                        itemFilerEditor.Click  += new EventHandler(itemFilerEditor_Click);
                        e.Menu.Items.Add(itemFilerEditor);
                    }

                    DevExpress.Utils.Menu.DXMenuItem itemFilerRow = new DevExpress.Utils.Menu.DXMenuItem();
                    itemFilerRow.Caption = "筛选";
                    itemFilerRow.Tag     = bandinfo.Band.Columns[0];
                    itemFilerRow.Click  += new EventHandler(itemFilerRow_Click);
                    e.Menu.Items.Add(itemFilerRow);

                    DevExpress.Utils.Menu.DXMenuItem splitFiler = new DevExpress.Utils.Menu.DXMenuItem();
                    splitFiler.Caption = "-";
                    e.Menu.Items.Add(splitFiler);

                    if (Column.OwnerBand.Fixed == DevExpress.XtraGrid.Columns.FixedStyle.None)
                    {
                        DevExpress.Utils.Menu.DXMenuItem itemFixRow = new DevExpress.Utils.Menu.DXMenuItem();
                        itemFixRow.Caption = "冻结列";
                        itemFixRow.Tag     = Column.OwnerBand;
                        itemFixRow.Click  += new EventHandler(itemFixRow_Click);
                        e.Menu.Items.Add(itemFixRow);
                    }
                    else
                    {
                        DevExpress.Utils.Menu.DXMenuItem itemFixCancel = new DevExpress.Utils.Menu.DXMenuItem();
                        itemFixCancel.Caption = "取消冻结";
                        itemFixCancel.Tag     = Column.OwnerBand;
                        itemFixCancel.Click  += new EventHandler(itemFixCancel_Click);
                        e.Menu.Items.Add(itemFixCancel);
                    }

                    DevExpress.Utils.Menu.DXMenuItem splitHide = new DevExpress.Utils.Menu.DXMenuItem();
                    splitHide.Caption = "-";
                    e.Menu.Items.Add(splitHide);


                    DevExpress.Utils.Menu.DXMenuItem itemHide = new DevExpress.Utils.Menu.DXMenuItem();
                    itemHide.Caption = "隐藏列";
                    itemHide.Tag     = Column.OwnerBand;
                    itemHide.Click  += new EventHandler(itemHide_Click);
                    e.Menu.Items.Add(itemHide);

                    DevExpress.Utils.Menu.DXMenuItem itemShow = new DevExpress.Utils.Menu.DXMenuItem();
                    itemShow.Caption = "显示所有列";
                    itemShow.Tag     = Column.OwnerBand;
                    itemShow.Click  += new EventHandler(itemShow_Click);
                    e.Menu.Items.Add(itemShow);
                }
            }
        }
Beispiel #3
0
        private void InsertMenu(DevExpress.XtraTreeList.Menu.TreeListColumnMenu Menu)
        {
            // Insert Menu
            DevExpress.XtraTreeList.Menu.TreeListColumnMenu menu = (DevExpress.XtraTreeList.Menu.TreeListColumnMenu)Menu;
            if (menu.Column == null) return;

            #region 1. Auto Filter - Dev Chưa hỗ trợ
            #endregion

            #region 2. Lọc nâng cao - Dev Chưa hỗ trợ
            #endregion

            #region 3. Tính toán trong nhóm
            DevExpress.Utils.Menu.DXMenuItem itemDisplayFooter;
            itemDisplayFooter = new DevExpress.Utils.Menu.DXMenuItem("Hiện thanh tính toán");
            itemDisplayFooter.BeginGroup = true;
            if (this.OptionsView.ShowSummaryFooter == true)
                itemDisplayFooter.Caption = "Ẩn thanh tính toán";
            itemDisplayFooter.Click += delegate(object sender, EventArgs e){
                this.OptionsView.ShowSummaryFooter = !this.OptionsView.ShowSummaryFooter;
            };
            Menu.Items.Add(itemDisplayFooter);
            #endregion

            #region 4. Canh lề
            DevExpress.Utils.Menu.DXSubMenuItem itemDisplayData = new DevExpress.Utils.Menu.DXSubMenuItem("Canh lề");
            itemDisplayData.BeginGroup = true;
            Menu.Items.Add(itemDisplayData);
            DevExpress.Utils.Menu.DXMenuCheckItem itemLeft = new DevExpress.Utils.Menu.DXMenuCheckItem("Lề trái");
            DevExpress.Utils.Menu.DXMenuCheckItem itemRight = new DevExpress.Utils.Menu.DXMenuCheckItem("Lề phải");
            DevExpress.Utils.Menu.DXMenuCheckItem itemCenter = new DevExpress.Utils.Menu.DXMenuCheckItem("Lề giữa");
            itemDisplayData.Items.Add(itemLeft);
            itemDisplayData.Items.Add(itemRight);
            itemDisplayData.Items.Add(itemCenter);
            itemLeft.Tag = menu.Column.AbsoluteIndex;
            itemRight.Tag = menu.Column.AbsoluteIndex;
            itemCenter.Tag = menu.Column.AbsoluteIndex;
            itemLeft.Click += new EventHandler(itemLeft_Click);
            itemRight.Click += new EventHandler(itemRight_Click);
            itemCenter.Click += new EventHandler(itemCenter_Click);
            itemLeft.Checked = (this.Columns[menu.Column.AbsoluteIndex].AppearanceCell.TextOptions.HAlignment == DevExpress.Utils.HorzAlignment.Near);
            itemRight.Checked = (this.Columns[menu.Column.AbsoluteIndex].AppearanceCell.TextOptions.HAlignment == DevExpress.Utils.HorzAlignment.Far);
            itemCenter.Checked = (this.Columns[menu.Column.AbsoluteIndex].AppearanceCell.TextOptions.HAlignment == DevExpress.Utils.HorzAlignment.Center);
            #endregion

            #region 5. Cố định cột - Chưa hỗ trợ
            #endregion

            #region 6. Xuất ra file
              bool isExport = true;

            if (_ExportElement != null)
            {
                if (_ExportElement is DevExpress.XtraBars.BarItem)
                {
                    if (((DevExpress.XtraBars.BarItem)_ExportElement).Visibility == DevExpress.XtraBars.BarItemVisibility.Never)
                        isExport = false;
                }
                else if (_ExportElement is DevExpress.XtraEditors.SimpleButton)
                {
                    if (((DevExpress.XtraEditors.SimpleButton)_ExportElement).Visible == false)
                        isExport = false;
                }
                else if (_ExportElement is System.Windows.Forms.ToolStripDropDownButton)
                {
                    if (((System.Windows.Forms.ToolStripDropDownButton)_ExportElement).Visible == false)
                        isExport = false;
                }
            }
            if (isExport)
            {   //SubMenu Export Data
                DevExpress.Utils.Menu.DXSubMenuItem itemExport = new DevExpress.Utils.Menu.DXSubMenuItem("Xuất ra file");
                itemExport.BeginGroup = true;
                Menu.Items.Add(itemExport);

                //Menu Export Excel
                DevExpress.Utils.Menu.DXMenuItem itemExportExcel = new DevExpress.Utils.Menu.DXMenuItem("Excel 97 - 2003");
                itemExport.Items.Add(itemExportExcel);
                itemExportExcel.Tag = "xls";
                itemExportExcel.Click += new EventHandler(itemExport_Click);

                DevExpress.Utils.Menu.DXMenuItem itemExportExcel2007 = new DevExpress.Utils.Menu.DXMenuItem("Excel 2007");
                itemExport.Items.Add(itemExportExcel2007);
                itemExportExcel2007.Tag = "xlsx";
                itemExportExcel2007.Click += new EventHandler(itemExport_Click);

                DevExpress.Utils.Menu.DXMenuItem itemPDF = new DevExpress.Utils.Menu.DXMenuItem("PDF");
                itemExport.Items.Add(itemPDF);
                itemPDF.Tag = "pdf";
                itemPDF.Click += new EventHandler(itemExport_Click);

                //Menu Export HTML
                DevExpress.Utils.Menu.DXMenuItem itemExportHTML = new DevExpress.Utils.Menu.DXMenuItem("HTML");
                itemExport.Items.Add(itemExportHTML);
                itemExportHTML.Tag = "html";
                itemExportHTML.Click += new EventHandler(itemExport_Click);

                //Menu Export Text
                DevExpress.Utils.Menu.DXMenuItem itemExportText = new DevExpress.Utils.Menu.DXMenuItem("RTF");
                itemExport.Items.Add(itemExportText);
                itemExportText.Tag = "rtf";
                itemExportText.Click += new EventHandler(itemExport_Click);
            }
            #endregion

            #region 7. In dữ liệu
              bool isPrint = true;
            if (_PrintElement != null)
            {
                if (_PrintElement is DevExpress.XtraBars.BarItem)
                {
                    if (((DevExpress.XtraBars.BarItem)_PrintElement).Visibility == DevExpress.XtraBars.BarItemVisibility.Never)
                        isPrint = false;
                }
                else if (_PrintElement is DevExpress.XtraEditors.SimpleButton)
                {
                    if (((DevExpress.XtraEditors.SimpleButton)_PrintElement).Visible == false)
                        isPrint = false;
                }
                else if (_PrintElement is System.Windows.Forms.ToolStripDropDownButton)
                {
                    if (((System.Windows.Forms.ToolStripDropDownButton)_PrintElement).Visible == false)
                        isPrint = false;
                }
            }
            if (isPrint)
            {
                DevExpress.Utils.Menu.DXMenuItem itemPrintData = new DevExpress.Utils.Menu.DXMenuItem("Xem trước khi in");
                itemPrintData.BeginGroup = true;
                Menu.Items.Add(itemPrintData);
                itemPrintData.Click += new EventHandler(itemPrintData_Click);
            }
            #endregion

            #region 8. Hình dạng cây - Chưa hỗ trợ
            #endregion

            #region 9. Hỗ trợ debug - Chưa hỗ trợ
            #endregion
        }