Ejemplo n.º 1
0
        /// <summary>
        /// 显示统计信息
        /// </summary>
        private void ShowSummaryTextInfo()
        {
            int icnt = this._SummaryContainer.Controls.Count;

            _FirstColSumTextType = SummaryTextType.None;
            foreach (Control ctr in this._SummaryContainer.Controls)
            {
                SummaryTextBox sumTextBox = ctr as SummaryTextBox;
                if (sumTextBox == null)
                {
                    continue;
                }
                if (sumTextBox.Name == "RowsHeader_Label")
                {
                    continue;
                }

                DataGridViewColumn currCell = this.GridViewColumns[sumTextBox.Name];
                if (currCell == null)
                {
                    continue;
                }
                sumTextBox.ForeColor = this._SummaryRowForeColor;
                sumTextBox.BackColor = this._SummaryRowBackColor;
                if (sumTextBox.IsHeaderLabel)
                {//如果SummaryTextBox的IsHeaderLabel为true则显示统计标题文本
                    sumTextBox.Text      = this._SummaryHeaderText;
                    sumTextBox.TextAlign = HorizontalAlignment.Center;
                    sumTextBox.Font      = new Font(this.DefaultCellStyle.Font, this._SummaryHeaderBold ? FontStyle.Bold : FontStyle.Regular);
                    _FirstColSumTextType = SummaryTextType.Text;
                    sumTextBox.Invalidate();
                    continue;
                }
                if (sumTextBox.IsSummary)
                {//如果是SummaryTextBox的IsSummary为true则计算对应列的合计
                    sumTextBox.Text         = this.CalcSum(currCell);
                    sumTextBox.FormatString = currCell.DefaultCellStyle.Format;
                    sumTextBox.TextAlign    = AligmentHelper.TranslateGridColumnAligment(currCell.DefaultCellStyle.Alignment);
                    sumTextBox.Invalidate();
                    continue;
                }
                if (!sumTextBox.IsHeaderLabel && !sumTextBox.IsSummary)
                {
                    sumTextBox.Text = "";
                    sumTextBox.Invalidate();
                }
            }
            this._SummaryRowHeaderLabel.Text = "√";
            //如果第一列是文本,则将统计文本设置到_SummaryRowHeaderLabel
            if (_FirstColSumTextType != SummaryTextType.Text)
            {
                this._SummaryRowHeaderLabel.Text = this._SummaryHeaderText;
            }
            this._SummaryRowHeaderLabel.TextAlign = HorizontalAlignment.Center;
            this._SummaryRowHeaderLabel.Font      = new Font(this.DefaultCellStyle.Font, this._SummaryHeaderBold ? FontStyle.Bold : FontStyle.Regular);
            this._SummaryRowHeaderLabel.Invalidate();
        }
Ejemplo n.º 2
0
 private void SetFormatFlags()
 {
     _Format.Alignment = AligmentHelper.TranslateAligment(TextAlign);
     _Format.Trimming  = _Trimming;
 }