WinForms C# DataGridView force refresh

2019-06-20 05:57发布

问题:

Baby steps rolling... I have a form with a data grid bound to a table. I have some textboxes on the form bound to the table[columns], so as I scroll the grid, the textboxes show corresponding data.

I go to an "Edit Mode" of the textboxes and change the content and hit a save button. The grid doesn't refresh the changed context until I physically click in the cell which forces a call to the tables OnChanging and OnChanged events...

How can I FORCE whatever event to "flush" the table at the end of my edit and have it refreshed in the datagridview.

Thanks

回答1:

Have you tried calling the dataGridView's Invalidate method?

this.dataGridView1.Invalidate();


回答2:

Are you using a BindingSource? If so, call its EndEdit method on the TextBox's Leave event.