在gridview的CustomDrawCell事件中,添加如下代码,则可实现行数据的颜色控制
if (gvData.GetDataRow(e.RowHandle) == null) return;
if (gvData.GetDataRow(e.RowHandle)["列名"].ToString()=="1" )
{
//该行数据的该列的值为1时,其背景色为gray
e.Appearance.BackColor = Color.Gray;
}
else
{
e.Appearance.BackColor = Color.Blue;
}
if (e.RowHandle == gvData.FocusedRowHandle)
{
e.Appearance.ForeColor = Color.White;
e.Appearance.BackColor = Color.RoyalBlue;
}