datagrid 上面的行的光亮条跟随鼠标移动
 if ((e.Item.ItemType==ListItemType.Item)||(e.Item.ItemType==ListItemType.AlternatingItem))
if ((e.Item.ItemType==ListItemType.Item)||(e.Item.ItemType==ListItemType.AlternatingItem))  {
            {  e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#ffffcc';this.style.color='buttontext';this.style.cursor='default';");
                e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#ffffcc';this.style.color='buttontext';this.style.cursor='default';");  //e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=this.getAttribute('BKC');");
                //e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=this.getAttribute('BKC');");  e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='';this.style.color='';");
                e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='';this.style.color='';");  }
            } 可以实现光亮条的选择
设置指定行的颜色
 if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
   if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) {
        { if (e.Item.ItemIndex == (i_currentline-1))
            if (e.Item.ItemIndex == (i_currentline-1)) {
            { e.Item.BackColor = System.Drawing.Color.Yellow;
                e.Item.BackColor = System.Drawing.Color.Yellow; }
            } }
        }行颜色交替显示:



 在DataGrid 里面的ItemDataBound事件
在DataGrid 里面的ItemDataBound事件

 //颜色交替显示
  //颜色交替显示 if (e.Item.ItemIndex >= 0 && e.Item.DataItem is DataRowView)
        if (e.Item.ItemIndex >= 0 && e.Item.DataItem is DataRowView) {
        { DataRowView row = (DataRowView)e.Item.DataItem;
            DataRowView row = (DataRowView)e.Item.DataItem; int numj = e.Item.Cells.Count;
            int numj = e.Item.Cells.Count; for (int j = 0; j < numj; j++)
            for (int j = 0; j < numj; j++) {
            { e.Item.Cells[j].ForeColor = System.Drawing.Color.Black;
                e.Item.Cells[j].ForeColor = System.Drawing.Color.Black; e.Item.Cells[j].BackColor = System.Drawing.Color.SkyBlue;
                e.Item.Cells[j].BackColor = System.Drawing.Color.SkyBlue; }
            } }
        }
 
                    
                 
            
 
             
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号