开发者

Update datasource from view values (WinForms DataGridView)

开发者 https://www.devze.com 2022-12-16 18:47 出处:网络
I am changing DataGridView cell values programmati开发者_如何学Gocally, but values are not pushed to bound datasource. They are pushed only for cells belonging to selected row. How can I ask the DataG

I am changing DataGridView cell values programmati开发者_如何学Gocally, but values are not pushed to bound datasource. They are pushed only for cells belonging to selected row. How can I ask the DataGridView to push rows values into datasource?

EDIT:

This code seems to do the trick, but may be some better solution?

grid.CurrentCell = cell;
cell.Value = "some value";
grid.EndEdit(0);


You shouldn't update the DataGridView cells, instead you should directly update the data source. If it implements INotifyPropertyChanged, the DataGridView will reflect the changes automatically

0

精彩评论

暂无评论...
验证码 换一张
取 消