如何更改第二列中具有特定值的行的颜色? [英] How to change color of row by which have specific value in 2nd column?

查看:68
本文介绍了如何更改第二列中具有特定值的行的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有dataGridView,其中最后一列是buttoncolumn,按下此按钮的行颜色变为红色。但我想将行颜色更改为已经为红色的白色,其cell1具有特定值,表示abc。通过apply(string str); if(str == abc)然后改变颜色。我从客户端收到一个字符,用另一种方法说$从那里我想改变颜色。怎么做?

i提供我的代码以便更好地理解。



谢谢。



I have dataGridView in which last column is buttoncolumn and by presssing this button row color changed to red . but i want to change row color to white which is already red , whose cell1 has specific value say "abc". by applying (string str) ; if (str == abc) then change color. and i receive one character from client in another method say "$" from there i want to change color . how to do that ?
i provide my code for better understanding.

thanks.

 case "$":
if (res.StartsWith("$"))
{
   DataGridViewRow row = new DataGridViewRow();
   string d = ifile.IniReadValue("Config Section", "INDENT_NO");

if (row.Cells[1].Value ==d )
{
foreach (DataGridViewRow rw in dataGridView1.Rows)
{
for(int m = 0; m<=dataGridView1.Rows.Count ; m++)
{
if (dataGridView1.Rows[m].Cells[1].Value.ToString() ==d )
{
for (int i = 0; i <= rw.Cells.Count - 1; i++)
{
rw.Cells[i].Style.BackColor = Color.White;
}
}
}
}
}
else { }
break;

推荐答案

从那里我想改变颜色。要做到这一点?

i提供我的代码以便更好地理解。



谢谢。



" from there i want to change color . how to do that ?
i provide my code for better understanding.

thanks.

 case "



if (res.StartsWith(
": if (res.StartsWith("


))
{
DataGridViewRow row = new DataGridViewRow();
string d = ifile.IniReadValue( 配置部分 INDENT_NO );

if (row.Cells [ 1 ]。值== d)
{
foreach (DataGridViewRow rw in dataGridView1.Rows)
{
for int m = 0 ; m< = dataGridView1.Rows.Count; m ++)
{
if (dataGridView1.Rows [m] .Cells [ 1 ]。Value.ToString()== d)
{
for int i = 0 ; i < = rw.Cells.Count - 1 ; i ++)
{
rw.Cells [i] .Style.BackColor = Color.White;
}
}
}
}
}
其他 {}
break ;
")) { DataGridViewRow row = new DataGridViewRow(); string d = ifile.IniReadValue("Config Section", "INDENT_NO"); if (row.Cells[1].Value ==d ) { foreach (DataGridViewRow rw in dataGridView1.Rows) { for(int m = 0; m<=dataGridView1.Rows.Count ; m++) { if (dataGridView1.Rows[m].Cells[1].Value.ToString() ==d ) { for (int i = 0; i <= rw.Cells.Count - 1; i++) { rw.Cells[i].Style.BackColor = Color.White; } } } } } else { } break;


这篇关于如何更改第二列中具有特定值的行的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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