Posted on 2006-12-20 21:39
玄铁剑 阅读(431)
评论(0) 编辑 收藏 引用 所属分类:
asp.net
private void MergeRows(DataGrid grid)
{
int row, icur, ispan;
int icol = grid.Columns.Count - 1;
int irow_count = grid.Items.Count - 1;
string strtmp;
for (int col = 0; col <= icol; col++)
{
if (grid.Columns[col].Visible == false)
continue;
ispan = 1;
row = 0;
icur = 0;
while (row <= irow)
{
strtmp = grid.Items[icur].Cells[col].Text.ToString();
row += 1;
if (row <= irow)
{
if (grid.Items[row].Cells[col].Text.ToString().Equals(strtmp))
{
ispan += 1;
grid.Items[icur].Cells[col].RowSpan = ispan;
grid.Items[row].Cells[col].Visible = false;
}
else
{
ispan = 1;
icur = row;
}
}
}
}
}