WinForms C# DataGridView 强制刷新
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/684421/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WinForms C# DataGridView force refresh
提问by DRapp
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...
我进入文本框的“编辑模式”并更改内容并点击保存按钮。网格不会刷新更改的上下文,直到我物理单击单元格,这会强制调用表 OnChanging 和 OnChanged 事件...
How can I FORCE whatever event to "flush" the table at the end of my edit and have it refreshed in the datagridview.
如何在编辑结束时强制任何事件“刷新”表格并在数据网格视图中刷新它。
Thanks
谢谢
采纳答案by BFree
Have you tried calling the dataGridView's Invalidate method?
您是否尝试过调用 dataGridView 的 Invalidate 方法?
this.dataGridView1.Invalidate();