DataBindingComplete被多次调用 [英] DataBindingComplete is getting called multiple times
问题描述
我有1个Datagridview,在我设置它的DataSource之后,它应该有3行。
我已将2个事件Habdlers附加到Datagrdview
void dgvProductList_RowsAdded(object sender,DataGridViewRowsAddedEventArgs e) < br>
{
//这被称为4次
}
private void dgvProductList_DataBindingComplete(object sender,DataGridViewBindingCompleteEventArgs e)
{
//被叫2次。
}
为什么这会发生,我该如何解决?
感谢提前...
当数据源的内容更改时,或 DataSource的值, DataMember 或 BindingContext 属性更改。
例如如果您分配Datasource,然后添加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屋!