2016-09-22 4 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 이벤트에 추가 할 수 있습니다.

관련 문제