鼠标移动,改变datagrid颜色

王朝c#·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航