如何更改GridView行的颜色 [英] how to change the gridview row color

查看:101
本文介绍了如何更改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

推荐答案

u可以像这样对rowdatabound进行操作

u can do on rowdatabound like this

e.Row.BackColor = System.Drawing.Color.Red


用于更改datagridview中行的背景颜色和字体颜色使用以下代码行:

For changing row''s background color and Font color in a datagridview use following lines of code:

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行的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆