WinForms C# DataGridView force refresh

こ雲淡風輕ζ 提交于 2019-12-10 13:34:30

问题


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.



来源:https://stackoverflow.com/questions/684421/winforms-c-sharp-datagridview-force-refresh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!