本文介绍了如何更改GridView行的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在onload运行时更改网格视图行的颜色
如果状态列=登录,我想更改行的颜色
谢谢
How to change the grid view row color wile running onload
i want change the color of the rows if the status columns = Login
Thanks
推荐答案
e.Row.BackColor = System.Drawing.Color.Red
int n = 0;
foreach (DataGridViewRow rw in dataGridView1.Rows)
{
// First put a check to avoid newRow error
if (rw.Index != dataGridView1.NewRowIndex) // To avoid newRow error
{
// You can replace your condition with the following line
if (String.IsNullOrEmpty(rw.Cells[0].Value.ToString()) != true)
{
DataGridViewRow bandrow = dataGridView1.Rows[n];
DataGridViewBand CatBand = bandrow;
DataGridViewCellStyle Rwstyle = new DataGridViewCellStyle();
Rwstyle.BackColor = Color.Lavender;
Rwstyle.ForeColor = Color.MediumBlue;
CatBand.DefaultCellStyle = Rwstyle;
}
}
n++;
}
对于其余的观点,请再解释一下您的问题.
For rest of the points please explain your problem little more.
这篇关于如何更改GridView行的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!