Blue Dream

记录成长的每一个脚印,写下漫长的程序人生
  首页  :: 订阅 订阅  :: 管理

DataGrid单元格合并函数

Posted on 2006-07-19 09:53  Dennis  阅读(221)  评论(0)    收藏  举报
DataGrid单元格合并函数
public void fDGrid_PreRender(object sender, System.EventArgs e)
{
if(this.fDGrid.Items.Count <=1)
{
return;
}
for( int col=0;col<5;col++)
{
TableCell oldtc = this.fDGrid.Items[0].Cells[col];
for(int i=1;i<this.fDGrid.Items.Count;i++)
{
TableCell tc = this.fDGrid.Items[i].Cells[col];
if(tc.Text == oldtc.Text)
{
tc.Visible = false;
if(oldtc.RowSpan == 0)
{
oldtc.RowSpan = 1;
}
oldtc.RowSpan = oldtc.RowSpan +1;
oldtc.VerticalAlign = VerticalAlign.Middle;
}
else
{
oldtc = tc;
}
}
}
}