• DataGrid的小技巧之toopTip


    经过一个月来的学习,我总结了用过的几个有关于DataGrid的小技巧:

    1.       为每列绑定相应的ToolTip,让其显示相关的信息。(如图)

    实现代码:

                                                                 private void O_dataGrid_ItemDataBound(object sender,

                               System.Web.UI.WebControls.DataGridItemEventArgs e)

           {

                  if(e.Item.ItemType == ListItemType.AlternatingItem ||

                                e.Item.ItemType == ListItemType.Item)

                  {

                         WebControl V_wc = (WebControl)e.Item.Cells[1].Controls[0];

                         V_wc.ToolTip = "库存量为 "+e.Item.Cells[4].Text+" 个单位";

                  }

           }

    2.鼠标移动到某一行动态显示不同的颜色。(如上图)

    private void O_dataGrid_ItemDataBound(object sender,

    System.Web.UI.WebControls.DataGridItemEventArgs e)

           {

                  if(e.Item.ItemType == ListItemType.AlternatingItem ||

                                e.Item.ItemType == ListItemType.Item)

                  {

                   e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='#FFC66C'");

                   e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='#FFFFFF'");

                         }

           }

    3. 如果DataGrid的项是用样式来确定显示颜色的,代码为:

    private void O_dataGrid_ItemDataBound(object sender,

    System.Web.UI.WebControls.DataGridItemEventArgs e)

           {

                  if(e.Item.ItemType == ListItemType.AlternatingItem ||

                                e.Item.ItemType == ListItemType.Item)

                  {

                                                      e.Item.Attributes.Add("onmouseover",
                                                                  "javascript:this.oldClassName=this.className;this.className='Over'");

                                                      e.Item.Attributes.Add("onmouseout",
                                                                 "javascript:this.className=this.oldClassName");

                   }

           }

  • 相关阅读:
    MyBatis基础
    Maven入门
    前后端分离之 跨域和JWT
    Hive 查询元数据库获取某个分区的count数
    Hadoop3.0 WordCount测试一直Accept 状态,Nodes of the cluster 页面node列表个数为0
    朴素字符串匹配
    iPhone6 AirDrop找不到我的mac解决方法!注销mac和iPhone的icloud账号
    RecyclerView 刷新后自动滚动的问题,notifyDataSetChanged 后自己滚动
    判断decimal 是否为整数
    微信jssdk config:invalid signature 签名错误 ,问题排查过程
  • 原文地址:https://www.cnblogs.com/aipeli/p/260055.html
Copyright © 2020-2023  润新知