Link to home
Start Free TrialLog in
Avatar of ARACK04
ARACK04

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of vo1d
vo1d
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial