DataGridViewCheckBoxCell 因 -> 值结果而损坏
我正在使用 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
}
}
现在我不知道 -> 价值可能是什么。 当我测试
dgvcbc->Value == true
它时它永远不会触发,或者
dgvcbc->Value == dgvcbc->TrueValue
当我在调试器中查看这些值时,两者都是“{true}”,但相等性从未被评估为 true
我什至
dgvcbc->TrueValue = true;
dgvcbc->Value == dgvcbc->TrueValue
再次尝试,两者都显示为“{true}”,但 //Do东西永远不会匹配
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
而不是 Value,它给出单元格的当前(格式化)值 - 哪一个取决于您想要如何访问它(是否处于编辑模式)
use either
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)