首页 > 开发 > 综合 > 正文

鼠标移动,改变datagrid颜色

2024-07-21 02:17:04
字体:
来源:转载
供稿:网友
sub datagrid1_itemdatabound(byval sender as object, byval e as system.web.ui.webcontrols.datagriditemeventargs)

if e.item.itemtype = listitemtype.item or _
e.item.itemtype = listitemtype.alternatingitem then

'---------------------------------------------------
' add the onmouseover and onmouseout method to the row of datagrid
'---------------------------------------------------
e.item.attributes.add("onmouseover", "this.style.backgroundcolor='silver'")
e.item.attributes.add("onmouseout", "this.style.backgroundcolor='white'")

end if

end sub

sub datagrid2_itemdatabound(byval sender as object, byval e as system.web.ui.webcontrols.datagriditemeventargs)

if e.item.itemtype = listitemtype.item or _
e.item.itemtype = listitemtype.alternatingitem then

'---------------------------------------------------
' add the onmouseover and onmouseout method a cell (column) of datagrid
'---------------------------------------------------
e.item.cells(1).attributes.add("onmouseover", "this.style.backgroundcolor='#ddeeff'")
e.item.cells(1).attributes.add("onmouseout", "this.style.backgroundcolor='white'")

'---------------------------------------------------
' change the mouse cursor of a particular cell (column) of datagrid
' (or you may do it for a whole row of datagrid :)
'---------------------------------------------------
e.item.cells(3).style("cursor") = "hand"

'---------------------------------------------------
' add the onclick alert messagebox to a particular cell (column) of datagrid
'---------------------------------------------------
e.item.cells(3).attributes.add("onclick", "alert('you click at id: " & e.item.cells(0).text & "!');")

end if
end sub

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表