As stated here the DataBindingComplete
event for a DataGridView is fired whenever the contents of the data source change, or a property such as DataSource
Yes, you can use DataSourceChanged
event, but be aware, that it occurs only when data source is changed. Additionally, DataBindingComplete
offers you information why it has happend - through e.ListChangedType
:
Reset = 0,// Much of the list has changed. Any listening controls should refresh all their data from the list.
ItemAdded = 1,// An item added to the list
ItemDeleted = 2,// An item deleted from the list.
ItemMoved = 3,// An item moved within the list.
ItemChanged = 4,// An item changed in the list.
PropertyDescriptorAdded = 5,// A System.ComponentModel.PropertyDescriptor was added, which changed the schema.
PropertyDescriptorDeleted = 6,// A System.ComponentModel.PropertyDescriptor was deleted, which changed the schema.
PropertyDescriptorChanged = 7// A System.ComponentModel.PropertyDescriptor was changed, which changed the schema.
According to this answer:
https://social.msdn.microsoft.com/forums/windows/en-us/50c4f46d-c3b8-4da7-b08f-a751dca12afd/databindingcomplete-event-is-been-called-twice
the whole thing happens because you don't have DataMember
property set in your dataGridView
. And you can set it only if you want to set particular table from database which is set as your DataSource
of dataGridView
. Other way - throws an exception.