Solved

Change font color in DataGridView entire row

Posted on 2011-03-08
5
1,297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

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…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

689 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