zoukankan      html  css  js  c++  java
  • GridView 合并单元格

     /// <summary>
        /// 合并单元格
        /// </summary>
        /// <param name="gridView">要合并单元格的表单</param>
        /// <param name="ArryJudgeCell">判断的列</param>
        /// <param name="ArryCellNum">要合并的列</param>
        public static void DoUniteGroupRowsGrid(GridView gridView, int[] ArryJudgeCell, int[] ArryCellNum)
        {
            int i = 0, rowSpanNum = 1;

            bool flagSame = true;

            while (i < gridView.Rows.Count - 1)
            {
                // 得到当前行
                GridViewRow gvrThis = gridView.Rows[i];

                for (++i; i < gridView.Rows.Count; i++)
                {
                    GridViewRow gvrNext = gridView.Rows[i];

                    for (int j = 0; j < ArryJudgeCell.Length; j++)
                    {
                        flagSame = true;

                        if (gvrThis.Cells[ArryJudgeCell[j]].Text != gvrNext.Cells[ArryJudgeCell[j]].Text)
                        {
                            flagSame = false;

                            break;
                        }
                    }

                    if (flagSame)
                    {
                        for (int k = 0; k < ArryCellNum.Length; k++)
                        {
                            gvrNext.Cells[ArryCellNum[k]].Visible = false;
                        }

                        rowSpanNum++;
                    }
                    else
                    {
                        for (int k = 0; k < ArryCellNum.Length; k++)
                        {
                            gvrThis.Cells[ArryCellNum[k]].RowSpan = rowSpanNum;
                        }
                        rowSpanNum = 1;
                        break;
                    }

                    if (i == gridView.Rows.Count - 1)
                    {
                        for (int k = 0; k < ArryCellNum.Length; k++)
                        {
                            gvrThis.Cells[ArryCellNum[k]].RowSpan = rowSpanNum;
                        }
                    }
                }
            }
        }

  • 相关阅读:
    Oracle启动关闭
    Open_stack 有虚拟机端口不通的问题
    关于Oracle归档的一些操作
    电脑无法开机 接通电源后主板有红灯闪烁的问题
    Centos7+python3.6+face-recognition
    电脑无法开机的问题-主板上有红色告警灯闪烁
    关于systemctl
    Vsftp搭建 for centos7
    外星人入侵——安装Pygame
    mysql索引原理详解
  • 原文地址:https://www.cnblogs.com/xianzuoqiaoqi/p/1424464.html
Copyright © 2011-2022 走看看