Example #1
0
 /// <summary>
 /// 汇总区带的汇总格子,按索引来查
 /// </summary>
 /// <param name="ColumnsIndex">索引是grid的column的index值</param>
 /// <returns>汇总数据格子。有可能为空(如果grid该列没有汇总要求)</returns>
 public DataGridViewFooterCell this[int ColumnsIndex]
 {
     get
     {
         DataGridViewFooterCell lvcell = null;
         foreach (DataGridViewFooterCell lvc in Cells)
         {
             if (ColumnsIndex == lvc.pv_ColumnIndex)
             {
                 lvcell = lvc;
             }
         }
         return(lvcell);
     }
 }
Example #2
0
        /// <summary>
        /// 汇总行 对应grid的列进行控件初始化。产生对象,且计算值。
        /// </summary>
        public void InitFooter()
        {
            DataGridViewFooterCell cellFooter = null;

            this.Cells.Clear();
            bool frozen = false;

            foreach (DataGridViewFooterTag lvFTag in pv_DataGridViewCust.PV_FooterColTag)
            {
                cellFooter = null;
                frozen     = pv_DataGridViewCust.Columns[lvFTag.ColumnIndex_Footer].Frozen;
                if (lvFTag.FooterStyle == DGVCFooterCellStyle.None)
                {
                    cellFooter = new DataGridViewFooterCell(DGVCFooterCellStyle.None, lvFTag.ColumnIndex_Footer, frozen);
                }

                if (lvFTag.FooterStyle.ToLower() == DGVCFooterCellStyle.Sum.ToLower())
                {
                    cellFooter = new DataGridViewFooterCell(DGVCFooterCellStyle.Sum, lvFTag.ColumnIndex_Footer, frozen);
                }
                if (cellFooter != null)
                {
                    if (frozen)
                    {
                        this.pv_PanelFrozen.Controls.Add(cellFooter);
                    }
                    else
                    {
                        this.pv_PanelScroll.Controls.Add(cellFooter);
                    }
                    this.Cells.Add(cellFooter);
                }
            }
            this.pt_ReCaculate();

            //this.ResumeLayout(false);
        }
Example #3
0
        /// <summary>
        /// 等着外部OnLayout调用
        /// </summary>
        /// <param name="rect"></param>
        public void LayoutControl(Rectangle rect)
        {
            DataGridViewFooterCell lvc = null;

            pv_FrozenCount = 0;//冻结列数量
            //最左边其实点
            int MostLeft = pv_DataGridViewCust.RowHeadersVisible ? pv_DataGridViewCust.RowHeadersWidth : 0;

            int leftw = MostLeft;
            int sumr  = 0;

            for (int i = 0; i < this.pv_DataGridViewCust.Columns.Count; i++)
            {
                if (this.pv_DataGridViewCust.Columns[i].Frozen)//对应列冻结
                {
                    pv_FrozenCount++;
                    leftw += this.pv_DataGridViewCust.Columns[i].Width;
                }
                else
                {
                    sumr += this.pv_DataGridViewCust.Columns[i].Width;
                }
                lvc = this[i];
                if (lvc == null)
                {
                    continue;
                }
                lvc.Width = this.pv_DataGridViewCust.Columns[i].Width - 3;
                if (this.pv_DataGridViewCust.Columns[i].Frozen)//对应列冻结
                {
                    lvc.Left = this.pv_DataGridViewCust.GetCellDisplayRectangle(i, -1, false).Left - 2;
                    //leftw += this.pv_DataGridViewCust.Columns[lvib].Width;
                }
                else
                {
                    lvc.Left = this.pv_DataGridViewCust.GetCellDisplayRectangle(i, -1, false).Left - leftw - 2;
                }
            }

            //冻结列

            ////this.RowHeaderWidth = this.pv_DataGridViewCust.RowHeadersWidth - 3;
            //int sumw = 0;

            //for (int lvib = 0;  lvib < this.pv_DataGridViewCust.Columns.Count; lvib++)
            //{
            //    sumw += this.pv_DataGridViewCust.Columns[lvib].Width;
            //    lvc= this[lvib];
            //    if (lvc==null){continue;}
            //    lvc.Width = this.pv_DataGridViewCust.Columns[lvib].Width;

            //}
            ////sumw += RowHeaderWidth;

            ////this._LeftView.Width = this._RightView.Width = sumw;

            //for (int lvib = pv_DataGridViewCust.Columns.Count - 1; lvib >= 0; lvib--)
            //{
            //    if (pv_DataGridViewCust.Columns[lvib].Frozen)
            //    {
            //        pv_FrozenCount = ++lvib;
            //        break;
            //    }
            //}
            ////最左侧行标题列可见时,要注意

            //if (pv_FrozenCount > 0)
            //{
            //    for (int lvib = 0; lvib < pv_FrozenCount; lvib++)
            //        leftw += pv_DataGridViewCust.Columns[lvib].Width;
            //}
            pv_PanelFrozen.Width = leftw;
            pv_PanelFrozen.Left  = rect.Left;

            pv_PanelScroll.Left  = leftw + rect.Left;
            pv_PanelScroll.Width = sumr;// rect.Width - leftw;

            //_RightView.Left = -(pv_DataGridViewCust.RowHeadersVisible ? pv_DataGridViewCust.RowHeadersWidth : 0) + 1;


            this.Width = rect.Width;
            this.Top   = rect.Top;
            this.Left  = rect.Left;
        }