Nejchy
Nejchy

Reputation: 666

Selected row does't update in DataGridView

I have a datatable bound to my datagridview. One of the columns is a DataGridViewCheckBoxColumn.

By clicking on a button you should change all checkboxes in the column to 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();
}

When I press the button everything seems ok(all checkboxes are true), but when I press update everything is updated except the row that was selected during btnPublishAll_Click.

What am I doing wrong?

Upvotes: 2

Views: 2333

Answers (1)

Nejchy
Nejchy

Reputation: 666

I found the problem!

I needed to add

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

instead of

this.dgrView.EndEdit();

Upvotes: 5

Related Questions