1.设置dataGridView中数据的显示风格,需要设置DefaultCellStyle里面的SelectionBackColor还有Font(字体设置).
设置某行的字体颜色代码:
dataGridView1.Rows[i].DefaultCellStyle.ForeColor=Color.Red;
2.设置datagridvie中使列和行的宽度不能由用户更改,代码:
this.dataGridView1.Columns[0].Frozen = true;
this.dataGridView1.Rows[0].Frozen = true;
3.设置datagridview中某行的某个字段字体的颜色:
dataGridView1.Rows[i].Cells["字段名"].Style.ForeColor = Color.Red;