如何更改第二列中具有特定值的行的颜色?
问题描述:
我有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;