C#中关于DataGridView行和列的背景色-前景色设置
1.设定DataGridView全部单元格的Style
DataGridView内所有单元格的Style变更,可以使用DataGridView对象的DefaultCellStyle属性实现。
//包含Header所有的单元格的背景色为黄色
DataGridView1.DefaultCellStyle.BackColor = Color.Yellow;
//包含Header所有的单元格的前景色为黄色
DataGridView1.DefaultCellStyle.ForeColor= Color.Yellow; //前景色设置,只需要将BackColor改为ForeColor即可
2.DataGridView.DefaultCellStyle属性可以对包含Header所有单元格的Style进行变更设定