views:

62

answers:

1

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?

+2  A: 

I found the problem!

I needed to add

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

instead of

this.dgrView.EndEdit();
Nejchy
thanks I had the same problem and this helped me out
m_oLogin