views:

354

answers:

1

I have DataGridView bind to bindingsource with datasource as list of active record models:

    BindingSource bs = new BindingSource();
    bs.DataSource = _user.Addresses;

Address has bool property named Actual, and my DataGirdView has CheckBoxColumn:

    DataGridViewCheckBoxColumn c = new DataGridViewCheckBoxColumn(false);
    c.Name = "actualColumn";
    c.HeaderText = "Aktualny";
    c.DataPropertyName = "Actual";
    c.AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
    addressesDataGridView.Columns.Add(c);

Data from database is displayed properly.

When I click on checked checkbox cell and unchecked it and then go to save button, property Actual in my bindingsource isn't unchecked.

When I click on checked checkbox cell and uncheck it and change row selection and then click save, button changes are visible in bindingsource.

Does a workaround exist for this issue?

+1  A: 

The problem is that the datagrid is not updating the underlying datasource.

You could try calling BindingSource.EndEdit as the first thing in the Save functionality.

You could also try to call EndCurrentEdit on the CurrencyManager that is bound to the control. To access it you do:

myCurrencyManager = (CurrencyManager)this.BindingContext[myTable];

fridrikr
None of your suggestion worked, but you have inspired me (for that +1 :), thanks)and following place on top of save functionality works:addressesDataGridView.EndEdit()
Adrian Serafin