简体   繁体   English

C#DataGridView绑定到动态数据

[英]C# DataGridView binding to dynamic data

I want to create an application that is refreshing DataGridView content with data about surrounding Wifi networks on every second. 我想创建一个应用程序,该应用程序每秒都使用有关周围Wifi网络的数据刷新DataGridView内容。 I wonder what would be the best binding solution for this task. 我想知道什么是此任务的最佳绑定解决方案。 I think using BindingList is meaningless, because it would update the datagridview on every single update on the List, while it would be better to refresh it after whole List is updated. 我认为使用BindingList是没有意义的,因为它会在List的每个更新上更新datagridview,而在更新整个List之后最好刷新它。 Meaby simple List and rebinding is appropriate here, what do you think? Meaby简单列表和重新绑定在这里很合适,您怎么看?

You can prevent the DataGridView from updating on every change to your BindingList by the following 您可以通过以下方法阻止DataGridView在对BindingList进行的每次更改时都进行更新:

myBindingList.RaiseListChangedEvents = false;
// Update BindingList
myBindingList.RaiseListChangedEvents = true;
myBindingList.ResetBindings();

The ResetBindings() call will cause your DataGridView to be refreshed to reflect the changes to myBindingList. ResetBindings()调用将使您的DataGridView刷新以反映对myBindingList的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM