views:

589

answers:

1

I'm using a DataGridViewCheckBoxCell but I can't figure out how to have the ->Value property working "correctly".

for (int i = this->dgvConfigs->Rows->Count - 1; i >= 0 ; i --){
  DataGridViewCheckBoxCell^ dgvcbc = (DataGridViewCheckBoxCell^) this->dgvConfigs->Rows[i]->Cells[2];
  // This is truely a weird behavior of the DataGridViewCheckBoxCell

  if (dgvcbc->Value->ToString() == "True"){
    // Do stuff
  }
}

Right now I can't figure out what ->Value could be. When I test

dgvcbc->Value == true

it never triggers, or

dgvcbc->Value == dgvcbc->TrueValue

When I look at those values in the debugger both are "{true}" but equality is never evaluated to true

I even tried

dgvcbc->TrueValue = true;
dgvcbc->Value == dgvcbc->TrueValue

again, both show up as "{true}" but the //Do Stuff is never matched

+1  A: 

use either

  • EditingCellFormattedValue, or
  • EditedFormattedValue

rather than Value, which gives the current (formatted) value of the cell - which one depends on how you want to access it (when in edit mode or not)

GalleySlave