会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
盛世唐朝
收集自己正学习的资料,方便自己学习,免得到处查找资料。
博客园
首页
新随笔
联系
订阅
管理
DataGrid相邻行有相同内容时对指定列合并
/**/
///
<summary>
///
DataGrid相邻行有相同内容时对指定列合并
///
</summary>
///
<param name="spangrid">
格式化的DataGrid的ID
</param>
///
<param name="spancell">
要合并的列
</param>
///
<param name="spanby">
合并所依据数据的列
</param>
public
void
FormatGrid(DataGrid spangrid,
int
spancell,
int
spanby)
{
if
(spanby
<
0
||
spanby
>
spangrid.Items.Count)
return
;
int
rowspan
=
1
;
for
(
int
i
=
1
;i
<
spangrid.Items.Count;i
++
)
{
if
(spangrid.Items[i].Cells[spanby].Text
==
spangrid.Items[i
-
1
].Cells[spanby].Text)
{
rowspan
+=
1
;
spangrid.Items[i].Cells[spancell].Visible
=
false
;
spangrid.Items[i
-
rowspan
+
1
].Cells[spancell].RowSpan
=
rowspan;
}
else
{
string
str
=
spangrid.Items[i].Cells[spanby].Text;
string
str1
=
spangrid.Items[i
-
1
].Cells[spanby].Text;
rowspan
=
1
;
}
}
}
posted on
2005-12-03 14:09
唐朝
阅读(
322
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部