0

In the DataGridView if you just have edited an field, you have to deselect or change the currently selected row in order for the changes to be applied in the database.
I was wondering if there is way to deselect the current row so I can update the changes in the database without clicking away from the current row?
Iam using an DataGridViewButtonColumn which opens another form, in which I edit the values, but when I try to update the changes to database it wont update(I have already binded these values to TextBox), because the row is currently being selected. But if I click another row in DataGridView and save, then the changes are applied.
I have already tried commands dgv.ClearSelection(); and dgv.CurrentCell = null;

Upset0987
  • 3
  • 1
  • Try calling the grid's `EndEdit()` method. – LarsTech Nov 19 '21 at 00:25
  • Didnt work, because I dont specifically edit the field, but use `BindingSource` to use selected rows fields in another form, but when I try to save from it, it wont update to db.(Yes it worked if I edit the field manually, but if I edit it programmatically it wont update) – Upset0987 Nov 19 '21 at 00:37
  • Please provide a [mre] that demonstrates/reproduces your claim. – JohnG Nov 19 '21 at 02:55
  • Please provide enough code so others can better understand or reproduce the problem. – Community Nov 19 '21 at 17:03

0 Answers0