您好,,我想请问一下C# datagrid控件 是怎么改变行背景色的??

2025-05-18 23:01:50
推荐回答(4个)
回答1:

如果你使用的是EasyUi的话。可以去改他里面的样式。

不然的话。你就用onmouseover 和onmouseout 去改变它每行的样式。

回答2:

在gridview控件右上方有个箭头的,里面鼠标单击可以选择编辑列选项,里面有每个列的设置,包括颜色,也可以直接套用模板。

回答3:

public static void OnMouseOver(GridViewRowEventArgs e, string MouseOverColor)
{
ListItemType itemType = (ListItemType)e.Row.RowType;
if (itemType == ListItemType.Item)
{

e.Row.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#ffffff';";
e.Row.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='" + MouseOverColor + "';cursor='hand';";

}
else if (itemType == ListItemType.AlternatingItem)
{
e.Row.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#ffffff';";
e.Row.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='" + MouseOverColor + "';cursor='hand';";
}
}

回答4:

datagrid控件里有许多属性的,你可以根据不同的属性来设置行背景色,如