• GridView显示数据特效——鼠标经过行背景高亮并呈手型


    在用GridView控件显示数据时,它的默认的样式很丑,也没有鼠标经过行背景高亮和鼠标呈现手型的特效,今天实现了这个特效。

    代码如下。


    //鼠标经过行背景高亮并变手型
            protected void ClassGridView_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                 int i;
                 //执行循环,保证每条数据都可以更新
                 for (i = 0; i <= ClassGridView.Rows.Count; i++)
                 {
                     //首先判断是否是数据行
                     if (e.Row.RowType == DataControlRowType.DataRow)
                     {
                         //当鼠标停留时更改背景色
                         e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='AliceBlue';this.style.cursor='pointer'");
                         //当鼠标移开时还原背景色
                         e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
                     }
                 }
            }

    如果只是想要行背景高亮或者添加其他特效只需要修改 e.Row.Attributes.Add中的内容即可。

  • 相关阅读:
    Latex: 插入数学公式
    Matlab: 作图
    Random Access Iterator 2019 ICPC 徐州网络赛(树上概率DP)
    2019南京网络赛D Robots(概率DP+拓扑序)
    HDU3507 Print Article(斜率优化+单调队列)
    hdu4632(区间dp)
    POJ 1651 Multiplication Puzzle 区间DP
    暑假集训
    POJ-2955(区间DP)
    kuangbin计算几何模板转载
  • 原文地址:https://www.cnblogs.com/wangzl1163/p/6341199.html
Copyright © 2020-2023  润新知