i have a userEventGrid_CellFormatting Event to change the cell back color when a specific text exists in a particular column and its working fine.
however if i set to Row back color instead of cell back color it doesnt work, where all the rows back color in gridview will be changed instead of specific rows only.
Please help me, what i am doing wrong...?
What I have tried:
code to change cell back color (working fine)
private void usrEventGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (this.usrEventGrid.Columns[e.ColumnIndex].Name == "Update")
{
if (e.Value != null)
{
string stringValue = (string)e.Value;
if (stringValue == "1A")
{
int rowIndex = (int)e.RowIndex;
e.CellStyle.BackColor = Color.Pink;
}
}
}
}
to highlight entire row i changed the above code from
e.CellStyle.BackColor = Color.Pink;
to
usrEventGrid.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Pink;
however the whole datagirdview is highlighted instead of specific row, please help