【问题标题】:Selected row does't update in DataGridView所选行在 DataGridView 中不更新
【发布时间】:2009-12-09 13:42:06
【问题描述】:

我有一个绑定到我的 datagridview 的数据表。其中一列是 DataGridViewCheckBoxColumn。

通过单击按钮,您应该将列中的所有复选框更改为 true。

private void btnPublishAll_Click(object sender, EventArgs e)
{
  for (int j = 0; j < this.dgrView.RowCount; j++)
  {
    this.dgrView[7, j].Value = true;
  }

  this.dgrView.EndEdit();
}

当我按下按钮时,一切似乎都正常(所有复选框都为真),但是当我按下更新时,所有内容都会更新,除了在 btnPublishAll_Click 期间选择的行。

我做错了什么?

【问题讨论】:

  • 能把更新方法的代码贴出来吗?

标签: c# winforms datagridview


【解决方案1】:

我发现了问题!

我需要添加

this.BindingContext[this.dgrView.DataSource].EndCurrentEdit();

而不是

this.dgrView.EndEdit();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-31
    • 2015-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-18
    • 1970-01-01
    相关资源
    最近更新 更多