0
我使用以下代碼更改datagridview的CellEnter事件中的單元格樣式。但如果我刪除if語句,所有行都將在數據綁定後格式化爲粗體。任何提示或建議?在RowIndex上更改DataGridviewCellStyle 0
DataGridViewCellStyle oStyle = new DataGridViewCellStyle();
oStyle.Font = new Font("Microsoft Sans Serif", 9.25f, FontStyle.Bold);
if (e.RowIndex > 0)
{
dataGridView1.Rows[e.RowIndex].Cells[0].Style = oStyle;
dataGridView1.Rows[e.RowIndex].Cells[1].Style = oStyle;
dataGridView1.Rows[e.RowIndex].Cells[2].Style = oStyle;
dataGridView1.Rows[e.RowIndex].Cells[3].Style = oStyle;
dataGridView1.Rows[e.RowIndex].Cells[4].Style = oStyle;
dataGridView1.Rows[e.RowIndex].Cells[5].Style = oStyle;
dataGridView1.Rows[e.RowIndex].Cells[6].Style = oStyle;
dataGridView1.Rows[e.RowIndex].Cells[7].Style = oStyle;
dataGridView1.Rows[e.RowIndex].Cells[8].Style = oStyle;
}