zoukankan
html css js c++ java
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
;
}
}
查看全文
相关阅读:
JavaScript函数中的this四种绑定形式
jQuery的html()、text()和val()的使用和区别
iframe-父子-兄弟页面相互传值(jq和js两种方法)
Spring Boot 嵌入式 Tomcat 文件上传、url 映射虚拟路径
SpringMVC上传图片
<iframe>和<frame>标签属性详解
Mybatis 事物回滚最简单的操作方式
SpringBoot配置log4j
springboot整合redis(集群)
Maven setting.xml简易配置
原文地址:https://www.cnblogs.com/adam/p/1023055.html
最新文章
【图像浏览】FastStone Image Viewer——快速、小巧、功能强大
【录教程必备】推荐几款屏幕录制工具(可录制GIF)
轻量却超强——推荐几款好用的截图工具
Windows中的键盘快捷方式大全
Listary Pro- 文件浏览与搜索增强的超级神器
centos下MySQL Workbench连接时崩溃的解决方法
宿舍管理系统
Java finally语句到底是在return之前还是之后执行?
记一次SQL注入实战
HTTP状态代码
热门文章
猜生日 Java小游戏
VMWare安装Mac OS X
2020年性价比台式电脑配置
CSS 使用伪元素清除浮动
解决Permission denied, please try again问题
Git使用总结(包含Git Bash和Git GUI的使用)
react对字符串转义成html并渲染
怎么通过原生JS改变元素的class属性
React开发环境配置
npm安装教程
Copyright © 2011-2022 走看看