【问题标题】:Auto Updating Databinding自动更新数据绑定
【发布时间】:2009-08-11 12:08:41
【问题描述】:

我有一个绑定到数据网格视图的对象(列表)集合。当我在集合中添加或删除对象时,如何在不重新绑定控件的情况下刷新 datagridview?

【问题讨论】:

  • asp.net? winform 还是 wpf?

标签: c# data-binding dataset


【解决方案1】:
  • 调用 DataGridView 的 BindingContext 的 EndCurrentEdit() 方法。
  • 先刷新 DataGridView,然后刷新 Parent(窗体或其他容器)

【讨论】:

    【解决方案2】:

    我还在另一个问题 (This one to be specific) 中找到了我的想法……我想我搜索的时间不够长。

    正确的做法是数据源实现IBindingList,SupportsChangeNotification返回true,发出ListChanged事件。但是,AFAIK,DataView 这样做...

    马克·格拉维尔

    【讨论】:

      猜你喜欢
      • 2016-02-22
      • 2014-09-13
      • 1970-01-01
      • 1970-01-01
      • 2019-05-18
      • 1970-01-01
      • 1970-01-01
      • 2011-04-16
      • 2010-10-05
      相关资源
      最近更新 更多