zoukankan      html  css  js  c++  java
  • 鼠标移动 改变Datagrid行的背景颜色

    protected void dgSjygl_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType==ListItemType.AlternatingItem))
            {
                //当鼠标移到的时候设置该行颜色
                e.Item.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699CC'");
                //当鼠标移走时还原该行的背景色
                e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
            }
        }

    在DataGrid 里面的ItemDataBound事件

    //颜色交替显示
            if (e.Item.ItemIndex >= 0 && e.Item.DataItem is DataRowView)
            
    {
                DataRowView row 
    = (DataRowView)e.Item.DataItem;
                
    int numj = e.Item.Cells.Count;
                
    for (int j = 0; j < numj; j++)
              
    {
                    e.Item.Cells[j].ForeColor 
    = System.Drawing.Color.Pink;
                    e.Item.Cells[j].BackColor 
    = System.Drawing.Color.Blue;
                }

            }

  • 相关阅读:
    *** 实现冒泡排序模板
    *** 实现stack模板
    python uses xml
    [转]给未来的电子通信工程师
    *** strRevert.cpp
    *** strlen.cpp
    *** checkRevStr.cpp 查看字符串是否是回文
    *** 自己代码:实现字符串比较
    *** 自写代码:查找两个字符串的最大公共子串
    *** 自写代码:在字符串中插入连续字符的个数
  • 原文地址:https://www.cnblogs.com/ZHF/p/1326290.html
Copyright © 2011-2022 走看看