I have a winform DataGridView
binded to a typed BindingSource
, itself binded to a DTO whose fields are read/write strings.
In my controller, I do View.ItemDtoBindingSource.DataSource = FoundResults
where FoundResults
is a List<ItemDto>
, and the data grid displays the expected values.
I want to allow the user to make changes and expect that the BindingSource
will update as the user changes cell values. Then an Update
button will fetch the contents of View.ItemDtoBindingSource
and make the desired changes in the back end.
I am not sure if I misunderstand the subtleties of data binding, but when I click on a cell on the data grid I am able to edit the value, but if I click away or press enter, the cursor leaves the cell and the value returns back to what it was before I tried to edit it (a behaviour expected if for example I had pressed Escape). Any reasons for this to happen?
I read that ReadOnly collections as a binding source may prevent from editing the datagrid, so I made sure I passed an IList<T>
instead of an IEnumerable<T>
, but this did not resolve the problem. I have also seen this and made sure VirtualMode = False
.