datagridview style

I'm trying to apply some style formatting to a datagridview at the start of my program.  Here is the body of the method which does this:

            MessageBox.Show("IN");
            foreach (DataGridViewRow row in dataGridView1.Rows)
                if (row.Cells[0].FormattedValue.ToString() != "Blah")
                    row.DefaultCellStyle.BackColor = Color.DarkGray;

This method is called at the very end of my constructor, and does in fact pop the the "IN" message.  The problem is that the cells don't change color as they should.  I have also put a button on my form, and set the event handler to do nothing but call this same method.  For some reason when I click on the button, the cells DO in fact change color as they should.

Does anyone know why I cannot change the backColor of the cells in the constructor, but I can in some random eventHandler?
ARACK04Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vo1dCommented:
it seems that the grid uses the property RowTemplate.DefaultCellStyle for painting, if a row is added.
if you want custom painting depending on the value of a cell, i think you will have to use the CellPainting event.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.