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].FormattedVal ue.ToStrin g() != "Blah")
row.DefaultCellStyle.BackC olor = 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?
MessageBox.Show("IN");
foreach (DataGridViewRow row in dataGridView1.Rows)
if (row.Cells[0].FormattedVal
row.DefaultCellStyle.BackC
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.