2011-09-14 3 views
1

winform에서 DataGridview를 새로 고칩니다. 이 내 서브 클래 싱 된 datagridview protected override void OnCellFormatting(DataGridViewCellFormattingEventArgs e) [두 번] 트리거하고 내 datagridviewcell의 backcolor 올바른 backcolor 가져옵니다.winform의 Datagridview에서 배경색을 칠하지 않음

그러나이 색은 채색되지 않았으며 셀을 클릭 할 때만 색칠됩니다. 마우스를 다시 클릭하면 protected override void OnCellFormatting [4 번]이 발생합니다.

이 동작이 필요합니까? 그것을 바꿀 수 있습니까?

답변

0

당신은 CellFormatting 이벤트에 배경색 설정을 시도 할 수 있습니다 :

private void myDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) 
{ 
    DataGridViewRow row = myDataGridView.Rows[e.RowIndex]; 
    row.DefaultCellStyle.BackColor = Color.Black; 
} 
관련 문제