Change font color in DataGridView entire row

I have a datagridview in which I change the font color after testing for certain criteria.  Here is the code snippet:

If dgvStatus = "Ho" Then
       e.CellStyle.ForeColor = Color.Red
End If

This changes the font color in the cell used in the selection criteria, but I want to change the font color in every cell in the row.  How can I do this?

T
T HoecherlDeveloperAsked:
Who is Participating?
 
PagodNaUtakConnect With a Mentor Commented:
Here is the code
If dgvStatus = "Ho" Then
'*** Note:change datagridview1 to the name of your datagirdview.
       DataGridView1.Rows(e.RowIndex).DefaultCellStyle.ForeColor = Color.Red
End If

Open in new window

0
 
PagodNaUtakCommented:
Try this code:

e.Row.ForeColor = System.Drawing.Color.Red
0
 
T HoecherlDeveloperAuthor Commented:
The only thing that pops up with intellisense is RowIndex.

If I just type in your suggestion, I get this error:

"'Row' is not a member of 'System.Windows.Form.DataGridViewCellFormattingEventArgs'."
0
 
PagodNaUtakCommented:
What event did you use?
0
 
T HoecherlDeveloperAuthor Commented:
Perfect.  Thank you.

T
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.