zoukankan
html css js c++ java
GridView鼠标移动行变色
方法一:
在GridView的
protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType
==
DataControlRowType.DataRow)
{
e.Row.Attributes.Add(
"
onMouseOver
"
,
"
SetNewColor(this);
"
);
e.Row.Attributes.Add(
"
onMouseOut
"
,
"
SetOldColor(this);
"
);
}
}
在页面中加入
<
SCRIPT language
=
javascript
>
var _oldColor;
function SetNewColor(source)
{
_oldColor
=
source.style.backgroundColor;
source.style.backgroundColor
=
'
#666666
'
;
}
function SetOldColor(source)
{
source.style.backgroundColor
=
_oldColor;
}
</
SCRIPT
>
方法二:
protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType
==
DataControlRowType.DataRow)
{
e.Row.Attributes[
"
onMouseOver
"
]
=
"
js.ItemOver(this)
"
;
}
}
在页面上加入
<
SCRIPT language
=
javascript type
=
text
/
javascript
>
var js
=
new
function()
{
if
(
!
objbeforeItem)
{var objbeforeItem
=
null
;var objbeforeItembackgroundColor
=
null
;}
this
.ItemOver
=
function(obj)
{
if
(objbeforeItem)
{objbeforeItem.style.backgroundColor
=
objbeforeItembackgroundColor;}
objbeforeItembackgroundColor
=
obj.style.backgroundColor;
objbeforeItem
=
obj;
obj.style.backgroundColor
=
"
#fcfcfc
"
;
}
}
</
SCRIPT
>
方法三:
protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType
==
DataControlRowType.DataRow)
{
//
鼠标移动到每项时颜色交替效果
e.Row.Attributes.Add(
"
OnMouseOut
"
,
"
this.style.backgroundColor='White';this.style.color='#003399'
"
);
e.Row.Attributes.Add(
"
OnMouseOver
"
,
"
this.style.backgroundColor='#6699FF';this.style.color='#8C4510'
"
);
//
设置悬浮鼠标指针形状为"小手"
e.Row.Attributes[
"
style
"
]
=
"
Cursor:hand
"
;
}
}
//
----------------------------------------
protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType
==
DataControlRowType.DataRow)
//
判断是否是DataRow,以防止鼠标经过Header也有效果
{
e.Row.Attributes.Add(
"
onmouseover
"
,
"
e=this.style.backgroundColor; this.style.backgroundColor='#cccccc'
"
);
e.Row.Attributes.Add(
"
onmouseout
"
,
"
this.style.backgroundColor=e
"
);
}
}
查看全文
相关阅读:
MFC中文件的查找、创建、打开、读写等
使用DOS比较两个txt文件的差异
HDU
LIS(两种方法求最长上升子序列)
7-17 奥运排行榜 (25 分)
区间DP
HDU-1864&&HDU-2602(01背包问题)
HDU-5968异或密码
Maximum Value(unique函数,lower_bound()函数,upper_bound()函数的使用)
博弈结论记录
原文地址:https://www.cnblogs.com/juan/p/1424642.html
最新文章
17.11.3 五子棋判断输赢
17.10.27作业 字符数组七则
洛谷 P1008 三连击 Label:水
洛谷 P1009 阶乘之和 Label:高精度
NOIP 2002过河卒 Label:dp
TYVJ P1068 STR Label:KMP匹配 不懂
TYVJ P1001 第K极值 Label:水
TYVJ P1002 谁拿了最多奖学金 Label:模拟 水
TYVJ P1012 火柴棒等式 Label:枚举
TYVJ P1063 数字串 Label:双指针 线性扫描
热门文章
TYVJ P1070 罗马数字 Label:一定要看的枚举
TYVJ P1090 母舰 Label:模拟,题目看清就好
如何使用UltraCompare对比两个文件夹内容差异
GetDlgItem
100层楼2个鸡蛋,如何得知鸡蛋能承受几层的撞击
为什么牛奶是方盒,可乐是圆瓶?
SQL Server 2012不支持从SQL Server 2000的备份进行还原
WPF
CString::Mid成员函数
CRect类
Copyright © 2011-2022 走看看