• <i id='QDNvi'><tr id='QDNvi'><dt id='QDNvi'><q id='QDNvi'><span id='QDNvi'><b id='QDNvi'><form id='QDNvi'><ins id='QDNvi'></ins><ul id='QDNvi'></ul><sub id='QDNvi'></sub></form><legend id='QDNvi'></legend><bdo id='QDNvi'><pre id='QDNvi'><center id='QDNvi'></center></pre></bdo></b><th id='QDNvi'></th></span></q></dt></tr></i><div id='QDNvi'><tfoot id='QDNvi'></tfoot><dl id='QDNvi'><fieldset id='QDNvi'></fieldset></dl></div>
  • <legend id='QDNvi'><style id='QDNvi'><dir id='QDNvi'><q id='QDNvi'></q></dir></style></legend>
    1. <small id='QDNvi'></small><noframes id='QDNvi'>

        <tfoot id='QDNvi'></tfoot>

        • <bdo id='QDNvi'></bdo><ul id='QDNvi'></ul>

        C# ListBox ObservableCollection&lt;T&gt;

        C# ListBox ObservableCollectionlt;Tgt;(C# ListBox ObservableCollectionlt;Tgt;)
      1. <small id='a8yCU'></small><noframes id='a8yCU'>

        • <bdo id='a8yCU'></bdo><ul id='a8yCU'></ul>

            • <tfoot id='a8yCU'></tfoot>
                  <tbody id='a8yCU'></tbody>

                1. <legend id='a8yCU'><style id='a8yCU'><dir id='a8yCU'><q id='a8yCU'></q></dir></style></legend>

                2. <i id='a8yCU'><tr id='a8yCU'><dt id='a8yCU'><q id='a8yCU'><span id='a8yCU'><b id='a8yCU'><form id='a8yCU'><ins id='a8yCU'></ins><ul id='a8yCU'></ul><sub id='a8yCU'></sub></form><legend id='a8yCU'></legend><bdo id='a8yCU'><pre id='a8yCU'><center id='a8yCU'></center></pre></bdo></b><th id='a8yCU'></th></span></q></dt></tr></i><div id='a8yCU'><tfoot id='a8yCU'></tfoot><dl id='a8yCU'><fieldset id='a8yCU'></fieldset></dl></div>
                  本文介绍了C# ListBox ObservableCollection&lt;T&gt;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用 ListBox.DataSource = ObservableCollection,但是我不知道如何在我的 OC 更新时让列表框自动更新.我可以在 OC 上挂钩 CollectionChanged 事件,但是我需要对列表框做什么才能使其更新?

                  I'm trying to use a ListBox.DataSource = ObservableCollection, however I can't figure out how to have the listbox automatically update when my OC updates. I can hook the CollectionChanged event on the OC, however what do I need to do to the listbox to make it update?

                  推荐答案

                  根据您的问题,听起来您正在尝试在 WinForms 应用程序中使用 ObservableCollection.

                  Based on your question, it sounds like you're trying to use ObservableCollection<T> in a WinForms application.

                  ObservableCollection<T> 主要用于 WPF 开发.在 WinForms 中,控件会随着集合的变化而自动更新,您的集合需要实现 IBindingList.

                  ObservableCollection<T> is primarily used in WPF development. In WinForms, for the control be automatically updates as the collection changes your collection needs to implement IBindingList.

                  最简单的解决方案是使用 BindingList<T> 而不是 ObservableCollection<T>.之后,您的控件应该随着集合的变化而更新.

                  The easiest solution is to use BindingList<T> instead of ObservableCollection<T>. After that, your controls should update as the collection changes.

                  MSDN:BindingList(T) 类

                  这篇关于C# ListBox ObservableCollection&lt;T&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                  listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                  Cannot remove items from ListBox(无法从列表框中删除项目)
                  Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                  Drag and drop from list to canvas on windows phone with MVVM(使用 MVVM 在 Windows 手机上从列表拖放到画布)
                  Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)
                  <legend id='qqkcv'><style id='qqkcv'><dir id='qqkcv'><q id='qqkcv'></q></dir></style></legend>

                    <tbody id='qqkcv'></tbody>
                3. <i id='qqkcv'><tr id='qqkcv'><dt id='qqkcv'><q id='qqkcv'><span id='qqkcv'><b id='qqkcv'><form id='qqkcv'><ins id='qqkcv'></ins><ul id='qqkcv'></ul><sub id='qqkcv'></sub></form><legend id='qqkcv'></legend><bdo id='qqkcv'><pre id='qqkcv'><center id='qqkcv'></center></pre></bdo></b><th id='qqkcv'></th></span></q></dt></tr></i><div id='qqkcv'><tfoot id='qqkcv'></tfoot><dl id='qqkcv'><fieldset id='qqkcv'></fieldset></dl></div>

                    1. <small id='qqkcv'></small><noframes id='qqkcv'>

                        1. <tfoot id='qqkcv'></tfoot>
                            <bdo id='qqkcv'></bdo><ul id='qqkcv'></ul>