2014-11-06 10 views
0

DatagridviewCheckbox 열을 추가하는 Datagridview가 있습니다. 내가 직면하고있는 문제는 내 프로그램을 실행 한 다음 내 체크 박스를 검사하려고 할 때 체크되지 않는다는 것입니다. 심지어 내가 활성화로하고 인터넷에서 다른 모든 솔루션을 시도에도 불구하고 DataGridView에의 편집을 설정하고 여기에 유래에서 만이 일 코드는 나를 위해 일하지만,이 코드를 사용, 난 단지 그것을 확인 할 수 있었다 :DatagridviewCheckboxColumn의 체크 박스가 선택되지 않는 이유는 무엇입니까?

private void data_grid1_CellContentClick(object sender, DataGridViewCellEventArgs e) 
{ 
     data_grid1.BeginEdit(true); 
     data_grid1.Rows[e.RowIndex].Cells["Select"].Value = true; 
} 

그러나 이것은 단지 한 번만 확인한 다음 다시 클릭 할 때 확인하지 않도록합니다. 내가 뭘해야하는지 도와주세요.

답변

0

마침내 나는 혼자 답을 얻었다. 여기에 해결책이 있습니다!

   data_grid1.Rows[e.RowIndex].Cells["Select"].Value = true; 
       if(!data_grid1.CurrentCell.Value.ToString().Equals(true)) 
       { 
        data_grid1.Rows[e.RowIndex].Cells["Select"].Value = true; 
       } 
       else if(data_grid1.CurrentCell.Value.ToString().Equals(true)) 
       { 
        data_grid1.Rows[e.RowIndex].Cells["Select"].Value = false; 
       }