会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
我的世界,我来创!
Create New World @@ $Adam$
博客园
首页
新随笔
联系
订阅
管理
DataGrid行单元格合并显示
//
绑定数据集
public
void
BindGrid()
{
DataSet ds
=
new
DataSet();
sqlDataAdapter2.Fill(ds);
DataGrid2.DataSource
=
ds.Tables[
0
];
DataGrid2.DataBind();
//
合并相同的单元格
string
strTemp;
int
intSpan
=
0
;
int
nowSpan
=
0
;
int
i, j;
for
(i
=
0
; i
<
DataGrid2.Items.Count; i
++
)
{
intSpan
=
1
;
strTemp
=
DataGrid2.Items[i].Cells[
0
].Text;
//
DataGrid2.Items[i].BackColor = Color.SkyBlue;
for
(j
=
i
+
1
; j
<
DataGrid2.Items.Count; j
++
)
{
if
(String.Compare(strTemp,DataGrid2.Items[j].Cells[
0
].Text)
==
0
)
{
intSpan
=
intSpan
+
1
;
DataGrid2.Items[i].Cells[
0
].RowSpan
=
intSpan;
//
DataGrid2.Items[i].Cells[1].RowSpan = intSpan;
//
DataGrid2.Items[i].Cells[2].RowSpan = intSpan;
DataGrid2.Items[i].Cells[
3
].RowSpan
=
intSpan;
//
DataGrid2.Items[j].BackColor = Color.SkyBlue;
DataGrid2.Items[j].Cells[
0
].Visible
=
false
;
//
DataGrid2.Items[j].Cells[1].Visible = false;
//
DataGrid2.Items[j].Cells[2].Visible = false;
DataGrid2.Items[j].Cells[
3
].Visible
=
false
;
}
}
nowSpan
+=
intSpan;
i
=
nowSpan
-
1
;
}
}
posted @
2008-01-02 12:42
Adam.Zhao
阅读(
335
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告