Solved

Change font color in DataGridView entire row

Posted on 2011-03-08
5
1,268 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:thoecherl
  • 3
  • 2
5 Comments
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 35076452
Try this code:

e.Row.ForeColor = System.Drawing.Color.Red
0
 

Author Comment

by:thoecherl
ID: 35077578
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
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 35077974
What event did you use?
0
 
LVL 8

Accepted Solution

by:
PagodNaUtak earned 500 total points
ID: 35078111
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
 

Author Closing Comment

by:thoecherl
ID: 35078727
Perfect.  Thank you.

T
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question