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
;
bool
flag
=
false
;
int
i, j;
for
(i
=
0
; i
<
DataGrid2.Items.Count; i
++
)
{
intSpan
=
1
;
strTemp
=
DataGrid2.Items[i].Cells[
0
].Text;
if
(flag
==
true
)
{
flag
=
false
;
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
;
}
}
}
else
{
DataGrid2.Items[i].BackColor
=
Color.White;
flag
=
true
;
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.White;
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
;
}
}
查看全文
相关阅读:
利用IDE自动生成Logger变量
浏览器跨域请求
linux shell 跟踪网站变动
linux shell 查找网站中无效的链接
linux shell 网页相册生成器
Shell帮你掌管上千台服务(多线程)
Ansible小实例
Shell监控公网IP-变化邮件报警
ffmpeg顺时针或逆时针旋转视频90,180度
Download youtube videos with subtitles using youtube-dl
原文地址:https://www.cnblogs.com/adam/p/1023368.html
最新文章
#6277. 数列分块入门 1
Eclipse自动添加继承重写代码块
Java封装练习题
eclipse自动生成构造方法
JS学习-第六节
JS学习-第五节
垃圾回收(GC)
JS学习-第四节
CSS预处理器-Less
TypeScript的基本使用(2)
热门文章
TypeScript的基本使用(1)
webpack开发环境配置(2)
webpack的基本使用(1)
git和github的基本使用(1)
linux服务器信息查询
存储过程循环嵌套(2)
Java实现抽奖功能
快速排序-Java实现
SpringBoot中,不同环境的日志配置
Vue项目部署到(nginx,tomcat)后的各种问题
Copyright © 2011-2022 走看看