2009-05-08 4 views
0

CheckBoxColumn이 선택되었을 때 remark 이벤트에이 이벤트를 사용하고 있기 때문에 "Value"속성을 사용하는 동일한 행의 현재 셀 [6] 값을 "프로그래밍 방식으로"바꿔야합니다. 기본적으로 "readOnly"속성은 = "true"입니다.DataGridViewCell에서 현재 값을 수정하는 데 DataGridViewCellEventArgs가 도움이되는 방법은 무엇입니까?

DataGridView1.DataSource는 LINQ2SQL 쿼리에서 검색됩니다.

void updateStyle_DataGridViewCellEventArgs(object sender, DataGridViewCellEventArgs e) 
{ 
    if (e.RowIndex == -1) 
     return; 
    else 
    { 
     DataGridView dgv = sender as DataGridView; 
     int vCHK = e.ColumnIndex; 
     if (vCHK != 0) 
      return; 
     else 
     { 
      DataGridViewCheckBoxCell temp = (DataGridViewCheckBoxCell)dgv.Rows[e.RowIndex].Cells[0]; 
      if ((bool)temp.EditedFormattedValue == true) 
      { 
       DataGridViewTextBoxCell xrow = (DataGridViewTextBoxCell)dgv.Rows[e.RowIndex].Cells[6]; 
       xrow.ReadOnly = false; 
       xrow.Value = "P"; 
       xrow.OwningRow.DefaultCellStyle.BackColor = Color.Wheat; 
      } 
      else 
      { 
       temp.OwningRow.DefaultCellStyle.BackColor = Color.White; 
      } 
     } 
    } 
} 

답변

1

DataSource에서 실제 개체/행을 찾고, 거기에있는 부울을 뒤집어 그리드를 다시 바인딩합니다. 그런 다음 CellFormatting 이벤트에서 BackColor를 설정할 수 있습니다.

관련 문제