Exemple #1
0
        private void gridView_GridMenuItemClick(object sender, DevExpress.XtraGrid.Views.Grid.GridMenuItemClickEventArgs e)
        {
            //汉化xtraGrid的统计菜单格式
            if (e.MenuType != DevExpress.XtraGrid.Views.Grid.GridMenuType.Summary)
            {
                return;
            }

            String strFormat = e.SummaryFormat;
            int    equInx    = strFormat.IndexOf("=");

            if (equInx > 0)
            {
                strFormat       = e.DXMenuItem.Caption + strFormat.Substring(equInx);
                e.SummaryFormat = strFormat;
            }
        }
Exemple #2
0
 private void gridView1_GridMenuItemClick(object sender, DevExpress.XtraGrid.Views.Grid.GridMenuItemClickEventArgs e)
 {
 }
        private void bandedGridView1_GridMenuItemClick(object sender, DevExpress.XtraGrid.Views.Grid.GridMenuItemClickEventArgs e)
        {
            if (e.SummaryItem == null)
            {
                return;
            }
            string _fname = e.SummaryItem.FieldName;

            switch (e.SummaryType)
            {
            case DevExpress.Data.SummaryItemType.Count:
                #region 处理求记录数

                if (!this.CountSummaryValues.ContainsKey(_fname))
                {
                    this.CountSummaryValues.Add(_fname, GetCountData(_fname));
                }
                if (this.CurrentValues.ContainsKey(_fname))
                {
                    this.CurrentValues[_fname] = this.CountSummaryValues[_fname];
                }
                else
                {
                    this.CurrentValues.Add(_fname, this.CountSummaryValues[_fname]);
                }
                e.SummaryItem.SummaryType   = SummaryItemType.None;
                e.SummaryItem.SummaryType   = SummaryItemType.Custom;
                e.SummaryItem.DisplayFormat = "记录数={0}";
                e.Handled = true;
                #endregion
                break;

            case DevExpress.Data.SummaryItemType.Sum:
                #region 处理求总数

                if (!this.SumSummaryValues.ContainsKey(_fname))
                {
                    this.SumSummaryValues.Add(_fname, GetSumData(_fname));
                }
                if (this.CurrentValues.ContainsKey(_fname))
                {
                    this.CurrentValues[_fname] = this.SumSummaryValues[_fname];
                }
                else
                {
                    this.CurrentValues.Add(_fname, this.SumSummaryValues[_fname]);
                }

                e.SummaryItem.SummaryType   = SummaryItemType.None;
                e.SummaryItem.SummaryType   = SummaryItemType.Custom;
                e.SummaryItem.DisplayFormat = "总和={0}";

                e.Handled = true;
                #endregion
                break;

            case DevExpress.Data.SummaryItemType.Average:
                #region 处理求平均数


                if (!this.AvgSummaryValues.ContainsKey(_fname))
                {
                    this.AvgSummaryValues.Add(_fname, GetAvgData(_fname));
                }
                if (this.CurrentValues.ContainsKey(_fname))
                {
                    this.CurrentValues[_fname] = this.AvgSummaryValues[_fname];
                }
                else
                {
                    this.CurrentValues.Add(_fname, this.AvgSummaryValues[_fname]);
                }
                e.SummaryItem.SummaryType   = SummaryItemType.None;
                e.SummaryItem.SummaryType   = SummaryItemType.Custom;
                e.SummaryItem.DisplayFormat = "平均数={0}";
                e.Handled = true;
                #endregion
                break;
            }
        }