急!怎样改变dataGrid的背影颜色?在线等待
怎样改变dataGrid的背影颜色 问题点数:20、回复次数:7Top
1 楼jxnetinfo(开心一聊)回复于 2003-11-02 11:45:48 得分 0
错了,是怎样改变dataGrid 指定行的背影颜色
Top
2 楼shuicaitian(水采田)回复于 2003-11-03 19:39:07 得分 0
我也关注Top
3 楼pp4u(方便面(当天结贴))回复于 2003-11-04 09:27:36 得分 5
e.Item.Attributes.Add("onclick", "this.style.backgroundColor='Silver'");
Top
4 楼meixiaofeng(yesmsn)回复于 2003-11-14 11:50:49 得分 0
在winform中呢?Top
5 楼linaren(JAVA/LINUX...)回复于 2003-11-14 12:09:50 得分 0
在winform与在webform中的方式不一样的Top
6 楼linaren(JAVA/LINUX...)回复于 2003-11-14 12:10:49 得分 5
在webform中也可以在PreRender事件中改变的Top
7 楼ytywj2003(.NET&Java)回复于 2003-11-14 13:51:31 得分 10
如果你用的是webform中的DataGrid,需要加入脚本语言才能实现选定行在鼠标移动时颜色发生改变,另外需要在
DataGrid中需要加入ItemDataBound事件,代码如下:
private void DG_UpDetail_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{//鼠标移动到指定行的高亮显示
e.Item.Cells[1].Style.Add("cursor","hand");//指定哪一列实现指针变手形
e.Item.Cells[2].Style.Add("cursor","hand");
if(e.Item.ItemType == ListItemType.Item )
{
e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='blue'");//指定鼠标移到记录上时的颜色
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='Silver'");//指定鼠标移出记录时的颜色
}
else if(e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='blue'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='SteelBlue'");
}
}
Top




