DataBindingComplete 被多次调用 [英] DataBindingComplete is getting called multiple times
问题描述
我正在用 C# 创建一个 windows 应用程序,
我有 1 个 Datagridview,在我设置它的 DataSource 后,它应该有 3 行.
我已将 2 个事件 Habdlers 附加到 Datagrdview
void dgvProductList_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{//这被调用了4次}私有无效 dgvProductList_DataBindingComplete(对象发送者,DataGridViewBindingCompleteEventArgs e){//被调用2次.}
为什么会发生这种情况,我该如何解决?
提前致谢...
来自 msdn 在线 DataBindingComplete 事件
<块引用><块引用>当数据源的内容或DataSource、DataMember或的值发生变化时,将引发此事件BindingContext 属性更改.
例如如果您正在分配数据源,然后添加 3 行 --> 4 次事件触发
I am creating a windows application in c#,
I have 1 Datagridview and after I set it's DataSource it should have 3 Rows.
I have attached 2 Event Habdlers to the Datagrdview
void dgvProductList_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)<br>
{
//this gets called 4 times
}
private void dgvProductList_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
//gets called 2 times.
}
Why does this Happen and how would I fix it?
Thanks In Advance...
From msdn online DataBindingComplete Event
This event is raised when the contents of the data source change or when the value of the DataSource, DataMember, or BindingContext property changes.
E.g. If you are assigning Datasource, and then adding 3 rows --> 4 times event fired
这篇关于DataBindingComplete 被多次调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!