【问题标题】:Automatically refreshing a listbox or datagrid bound to an arraylist?自动刷新绑定到数组列表的列表框或数据网格?
【发布时间】:2011-12-23 20:14:08
【问题描述】:

我正在使用 Windows 窗体应用程序将列表框绑定到数组列表,使用这些twoarticles 中描述的技术。

ListBox1.DisplayMember = "LongName";
ListBox1.ValueMember = "ShortName";

或用于数据网格视图

dataGridView1.DataSource = customers;

在 WPF 中,您可以绑定到可观察的集合,并且当列表发生更改时,网格将自动更新。但我似乎无法在 Windows 窗体中复制它。

是我遗漏了什么,还是这不可能?

【问题讨论】:

    标签: c# windows forms binding listbox


    【解决方案1】:

    对于 Windows 窗体中的“双向”绑定,您需要使用实现 IBindingList 的集合。

    this article 中有一些有用的信息。

    【讨论】:

    • 搜索几个小时只得到了糟糕的例子。在五分钟内,你让我走上了正确的道路。谢谢。
    猜你喜欢
    • 2012-03-23
    • 1970-01-01
    • 1970-01-01
    • 2011-07-10
    • 2012-06-13
    • 2016-04-30
    • 1970-01-01
    • 1970-01-01
    • 2019-06-02
    相关资源
    最近更新 更多