【问题标题】:DataGridViewCheckBoxCell is broken for ->Value resultDataGridViewCheckBoxCell 因 -> 值结果而损坏
【发布时间】:2008-10-28 18:23:52
【问题描述】:

我正在使用 DataGridViewCheckBoxCell,但我不知道如何让 ->Value 属性“正确”工作。

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
  }
}

现在我无法弄清楚 ->Value 可能是什么。当我测试时

dgvcbc->Value == true

它永远不会触发,或者

dgvcbc->Value == dgvcbc->TrueValue

当我在调试器中查看这些值时,它们都是“{true}”,但从未将相等性评估为 true

我什至尝试过

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

同样,两者都显示为“{true}”,但 //Do Stuff 永远不会匹配

【问题讨论】:

    标签: .net c++ forms datagridviewcheckboxcell


    【解决方案1】:

    使用任一

    • 编辑CellFormattedValue,或
    • EditedFormattedValue

    而不是 Value,它给出了单元格的当前(格式化)值 - 取决于您想要如何访问它(在编辑模式下与否)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-23
      • 2012-05-16
      • 1970-01-01
      • 1970-01-01
      • 2018-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多