有没有办法使子列表与主列表的内容保持同步?
我将有一个“主列表”(最好是 BindingList 类型)。在另一个课程中,我有一个子列表,它由“主列表”的某些元素组成。类的每个实例都有不同的元素。有没有办法使每个子列表与“主列表”保持同步?
I will have one 'master list' (preferably of type BindingList). In another class I have a sublist, which is composed of certain elements of the 'master list'. Each instance of the class has different elements. Is there a way to keep each of the sublists synchronized with the 'master list'?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过扩展列表并添加复合对象来创建所需的列表类型,并在更新“主”列表时同步这些对象。
这是我在 java 中的做法,你可以在 c# 中做同样的事情,但我不记得确切的语法。您当然可以扩展您喜欢的任何列表类型。
You could create that type of list you need by extending your list and add composite objects that you also synchronize whenever you update your "main" list.
Here is how I would do it in java, you can do the same in c# but right know i dont remember exact syntax. You could ofcourse extend what ever list type you like.
也许您需要的是 ObseravleCollection 集合。
请参阅此了解更多详情
1. http://www.codeproject.com/KB/silverlight/SLListVsOColections.aspx
2. http://karlhulme.wordpress.com/2007/03/ 04/synchronizedobservablecollection-and-bindablecollection/
Perhaps what you need is ObseravleCollection collection.
Please refer this for more details
1. http://www.codeproject.com/KB/silverlight/SLListVsOCollections.aspx
2. http://karlhulme.wordpress.com/2007/03/04/synchronizedobservablecollection-and-bindablecollection/