• 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;
                        }
                    }
                }
            }
        }

  • 相关阅读:
    mysql5.7慢查询开启配置
    easyui的datagrid删除一条记录后更新出问题
    easyui跨iframe属性datagrid
    struts2笔记12-声明式异常
    struts2笔记11-OGNL
    struts2笔记10-值栈
    linux命令学习03-grep
    struts2笔记09-动态方法调用
    1、GIT简介
    玩转Python语言之4:奇技淫巧
  • 原文地址:https://www.cnblogs.com/xianzuoqiaoqi/p/1424464.html
Copyright © 2020-2023  润新知