DataBindingComplete获取调用多次 [英] DataBindingComplete is getting called multiple times

查看:1281
本文介绍了DataBindingComplete获取调用多次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建在C#Windows应用程序,



我有1的DataGridView和我设置后的DataSource它应该有3行。



我附上2事件Habdlers到Datagrdview

 无效dgvProductList_RowsAdded(对象发件人,DataGridViewRowsAddedEventArgs E) < BR> 
{
//这个被调用4次
}

私人无效dgvProductList_DataBindingComplete(对象发件人,DataGridViewBindingCompleteEventArgs E)
{
//被调用2次。
}



为什么会出现这种情况,我会怎么解决?



在此先感谢...


解决方案

From MSDN联机DataBindingComplete事件





将引发此事件当数据源改变或在内容数据源的值 数据成员的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆