for the first 4 row it is working from row 4 to 7 set different fore and back color in data grid view
for the first 4 rows it is working fore and Back color.
Then for another 4 rows[4 to 7 rows] i want to set different fore color and back color.
Code as follows;
For the First 4 rows code as follows;
int irows = 0;
for (int i = 0; i<; datagridView.RowCount; i++)
{
datagridView.Rows[irows].DefaultCellStyle.ForeColor = Color.Purple;
datagridView.Rows[irows].DefaultCellStyle.BackColor = Color.RosyBrown;
irows = irows + 1;
}
for the another 4 rows code as follows [row no 4 to 7]
int irows1 = 4;
for(int i =4; i<7; i++)
{
datagridView.Rows[irows1].DefaultCellStyle.ForeColor = Color.Blue;
datagridView.Rows[irows1].DefaultCellStyle.BackColor = Color.Aqua;
irows = irows + 1;
}
i tried the above code for another 4 rows [row 4 to 7];
but only for the 4 th row color changing but not for the remaining rows 5 to 7.it is not changing.please help me.
from my above code,what is the mistake please rectify.i tried but is not working.
Answers
Know the answer? Post it. Somebody with the same question will find it here.