Solved

Change font color in DataGridView entire row

Posted on 2011-03-08
5
1,241 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now