Solved

Change font color in DataGridView entire row

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

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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