C#GriewView와 같은 열을 병합한 예제

1196 단어
 
  
 ///
    /// GridView ( )
    ///

    ///
    ///
    public static void GroupCol(GridView GridView1, int cols)
    {
        if (GridView1.Rows.Count < 1 || cols > GridView1.Rows[0].Cells.Count - 1)
        {
            return;
        }
        TableCell oldTc = GridView1.Rows[0].Cells[cols];
        for (int i = 1; i < GridView1.Rows.Count; i++)
        {
            TableCell tc = GridView1.Rows[i].Cells[cols];
            if (oldTc.Text == tc.Text)
            {
                tc.Visible = false;
                if (oldTc.RowSpan == 0)
                {
                    oldTc.RowSpan = 1;
                }
                oldTc.RowSpan++;
                oldTc.VerticalAlign = VerticalAlign.Middle;
            }
            else
            {
                oldTc = tc;
            }
        }
    }

좋은 웹페이지 즐겨찾기