DataGridView - DefaultCellStyle, rows and columns propriority
Posted
by
angelPL
on Stack Overflow
See other posts from Stack Overflow
or by angelPL
Published on 2011-01-12T20:49:52Z
Indexed on
2011/01/12
20:54 UTC
Read the original article
Hit count: 146
Hi!
In C#, in DataGridView I want to set the BackColor property for the first row and first column. And the cell from first row and first column, should have property from first column, not row - but it does.
For example: (table 3 x 3); 'X' - property for first row, 'Y' - property for first column, 'a' - default property
- should be:
Y X X
Y a a
Y a a
- but is:
X X X
Y a a
Y a a
There is no matter which property I set first:
dataGridView1.Rows[0].DefaultCellStyle.BackColor = Color.Lavender;
dataGridView1.Columns[0].DefaultCellStyle.BackColor = Color.Beige;
or:
dataGridView1.Columns[0].DefaultCellStyle.BackColor = Color.Beige;
dataGridView1.Rows[0].DefaultCellStyle.BackColor = Color.Lavender;
Sorry for my english...
© Stack Overflow or respective owner