【问题标题】:why is a User Control's BindingSource.CurrentChanged method being called 3 times when a form is loaded first time?为什么在第一次加载表单时会调用用户控件的 BindingSource.CurrentChanged 方法 3 次?
【发布时间】:2014-08-05 11:05:55
【问题描述】:

我有一个用户控件,其中包含一个绑定的 datagridview 和一个用于在绑定源中加载数据的集合。

当我想第一次从另一个表单加载控件时,BindingSource.CurrentChanged 方法被调用了 3 次!但是当我单击下一个按钮以查看加载的 datagridview 控件上的下一个对象时,BindingSource.CurrentChanged 仅被调用一次。

有人可以解释一下为什么第一次调用 CurrentChanged 方法 3 次,但在控件已经加载时只调用一次?

【问题讨论】:

    标签: datagridview bindingsource


    【解决方案1】:

    只要 Current 属性因以下任何原因发生更改,就会引发 CurrentChanged 事件:

    The current position of the List changes.
    
    The DataSource or DataMember properties change.
    
    The membership of the underlying List changes, which causes Position to refer to a different item. Examples include adding or deleting an item before the current item, deleting or moving the current item itself, or moving an item to the current position.
    
    The underlying list is refreshed by a new sorting or filtering operation.
    

    更多信息请参考https://social.msdn.microsoft.com/Forums/windows/en-US/5f968c71-a979-4e80-9896-94736e832f0c/bindingsource-currentchanged-event?forum=winformsdatacontrols页面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-16
      • 2020-08-19
      • 2016-12-08
      相关资源
      最近更新 更多