当前位置:编程学习 > C#/ASP.NET >>

帮忙解释解释合并单元格的段代码,

#region 合并单元格
    protected void Unite(GridView gv)
    {
        int i;
        string LastType1;
        int LastCell;
        if (gv.Rows.Count > 0)
        {
            for (int j = 0; j < 6; j++)
            {
                if (j != 1 && j != 2 && j != 3)
                {
                    LastType1 = gv.Rows[0].Cells[j].Text;
                    gv.Rows[0].Cells[j].RowSpan = 1;
                    LastCell = 0;

                    for (i = 1; i < gv.Rows.Count; i++)
                    {
                        if (gv.Rows[i].Cells[j].Text == LastType1)
                        {
                            gv.Rows[i].Cells[j].Visible = false;
                            gv.Rows[LastCell].Cells[j].RowSpan++;
                        }
                        else
                        {
                            LastType1 = gv.Rows[i].Cells[j].Text;
                            LastCell = i;
                            gv.Rows[i].Cells[j].RowSpan = 1;
                        }
                    }
                }
            }
        }
    }
    #endregion
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,