本文介绍了数据绑定到列表的DataGridView不会更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个DataGridView数据绑定到BindingSource,它又连接到一个对象列表。数据绑定设置完成后,我从后台线程中填充列表(当然使用Form.Invoke)。问题是网格没有更新。我可以在调试器中看到BindingSource包含项目,DataGridView已经连接到它,但是项目不显示。什么是错误?解决方案
我想到了这一点。我需要使用BindingList<>而不是List<>。
I have a DataGridView databound to BindingSource which is in turn connected to a list of objects. After the data bindings are set up I'm populating the list from the background thread (using Form.Invoke of course). The problem is that the Grid is not updated. I can see in the debugger that the BindingSource contains items and DataGridView is connected to it, but the items are not displayed. What is wrong?
解决方案
I figured this out. I need to use BindingList<> instead of List<>.
这篇关于数据绑定到列表的DataGridView不会更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!