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
;
}
}
查看全文
相关阅读:
Python--json处理
Python--加密模块
Python--函数即变量
bzoj 2276: [Poi2011]Temperature
1616: [Usaco2008 Mar]Cow Travelling游荡的奶牛
2017 9 15 noip模拟赛
bzoj 1612: [Usaco2008 Jan]Cow Contest奶牛的比赛
2017 9 11 noip模拟赛T2
URAL 1613. For Fans of Statistics (2017 9 6 noip模拟赛T3)
codeforces 105 B. Dark Assembly(birbe贿赂 noip模拟赛)
原文地址:https://www.cnblogs.com/adam/p/1023368.html
最新文章
【Spring】【5】 PUT请求接收不到参数
【MySQL】【6】分组后获取每个组排序后的第一条数据
【Java】【49】判断String字符串数组中是否存在某个值
感悟创业
参加医疗博览会心得
销售就是聊天,记住4个顶尖话术就够了!
王老吉为何败给加多宝?
病入膏肓
管理者思考
管理人员如何树立自己的“威信”
热门文章
一生中要走完的风景线
商鞅变法之困
曾对你许下诺言 今生我至死不渝
Python--datetime模块
Python--迁移redis脚本
Python--操作redis
Python--操作mysql
python--随机数模块
Python--时间模块
Python--常用的模块
Copyright © 2011-2022 走看看