鼠标移动,改变DataGrid颜色
发布日期:2021-06-30 19:00:51 浏览次数:3 分类:技术文章

本文共 1666 字,大约阅读时间需要 5 分钟。

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

转载地址:https://linuxstyle.blog.csdn.net/article/details/149755 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:VB.NET and C# 语法比较手册
下一篇:PHP中的页面跳转

发表评论

最新留言

逛到本站,mark一下
[***.202.152.39]2024年04月06日 21时48分12秒