为什么在第一次加载表单时会调用User Control的BindingSource.CurrentChanged方法3次?

时间:2014-08-05 11:05:55

标签: datagridview bindingsource

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

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

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

1 个答案:

答案 0 :(得分:0)

每当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页。

相关问题