/// <summary>
/// 合并GridView中某列相同信息的行(单元格) /// </summary> /// <param name="GridView1">GridView</param> /// <param name="cellNum">第几列</param> public static void GroupRows(GridView GridView1, int [] cellNum)//已经改动过了现在是对指定多列后把相同信息合并 { //int []arr = new int[cellNum.Length]; //arr = cellNum; for (int num = 0; num < cellNum.Length; num++) { int i = 0, rowSpanNum = 1; while (i < GridView1.Rows.Count - 1) { GridViewRow gvr = GridView1.Rows[i]; for (++i; i < GridView1.Rows.Count; i++) { GridViewRow gvrNext = GridView1.Rows[i]; if (gvr.Cells[cellNum[num]].Text == gvrNext.Cells[cellNum[num]].Text) { gvrNext.Cells[cellNum[num]].Visible = false; rowSpanNum++; } else { gvr.Cells[cellNum[num]].RowSpan = rowSpanNum; rowSpanNum = 1; break; } if (i == GridView1.Rows.Count - 1) { gvr.Cells[cellNum[num]].RowSpan = rowSpanNum; } } } } }