c# DataGrid 绑定到 List
我有一个绑定到 List 对象的 dataGrid,通过调用可以正常工作...
dgList.DataSource = carList;
但是我有代码通过轮询服务器来更新后台线程上的 carList,并根据年龄进行删除。数据网格似乎根本没有更新,我尝试调用 .Update()
但没有效果。
这可能吗?
该列表定义为
List<Car> = carList = new List<Car>();
I have a dataGrid bound to a List object and this works fine by calling...
dgList.DataSource = carList;
However I have code that updates the carList on background threads by polling servers and also deletes based on age. The datagrid does not seem to update at all, I tried calling .Update()
and that has no effect.
Is this possible?
The list is defined as
List<Car> = carList = new List<Car>();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
刷新
不起作用,因为它只会重绘控件:最简单的解决方案可能是再次使用
DataSource
重新绑定:Refresh
won't work because it only redraws the control:The simplest solution is likely to rebind using
DataSource
again:您必须再次使用 DataBind 重新绑定数据
对于 WinForms, :您有吗尝试再次重置源?
如果不使用 BindingSource 而不是原始列表。
You have to rebind the data with DataBind again
as for WinForms: have you tried to reset the source again?
If not use a BindingSource instead of the raw list.