Hi, HMote
Yes, it is. Presuming that "j" is an int according to which column you gonna to judge the value.
You can make a loop like the example:
(int i = 0; i < dataGridView1.Rows.Count; i++)
if (Convert.ToInt32(dataGridView1.Rows[ i ].Cells[ j ].Value) < 0)
Color.Blue;Color.Red;
//dataGridView1.Rows[ i ].Cells[ j ].Style -- whatever you want it to be...
Try this...
Code Block
(int i = 0; i < dataGridView1.Rows.Count; i++)
if (Convert.ToString(dataGridView1.Rows[ i ].Cells[<check cell>].Value)== "True")
dataGridView1.Rows[ i ].Cells[<change cell>].Style.ForeColor = Color.Red;
Hi, HMote
Yes, it is. Presuming that "j" is an int according to which column you gonna to judge the value.
You can make a loop like the example:
(int i = 0; i < dataGridView1.Rows.Count; i++)
if (Convert.ToInt32(dataGridView1.Rows[ i ].Cells[ j ].Value) < 0)
Color.Blue;Color.Red;
//dataGridView1.Rows[ i ].Cells[ j ].Style -- whatever you want it to be...
I loved this, it worked! Further question for my use.
I want to do the same thing, but I only want my cell to become red if Another cell on the same row is marked to "True". Can that be done, I've tried varying this code snippet, to no avail.
|