2016-09-22 5 views
0

次のコードを使用して、DataGridviewのCellEnterイベントのセルスタイルを変更します。 if文を削除すると、データバインド後にすべての行が太字になります。任意のヒントやアドバイス?RowIndex 0でDataGridviewCellStyleを変更する

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; 
      } 

答えて

0

あなたが期待した動作を正しく理解している場合。 上記のコードをCellMouseClickイベントに追加できます。

関連する問題