System.Windows.Forms.BindingSource.AddingNew Event

Occurs before an item is added to the underlying list.


public event System.ComponentModel.AddingNewEventHandler AddingNew


The BindingSource.AddingNew event occurs before a new object is added to the underlying list represented by the BindingSource.List property. This event is fired after the BindingSource.AddNew method is called, but before the new item is created and added to the underlying list. By handling this event, the programmer can provide custom item creation and insertion behavior without being forced to derive from the System.Windows.Forms.BindingSource class. This is accomplished in the event handler by setting the System.ComponentModel.AddingNewEventArgs.NewObject property of the System.ComponentModel.AddingNewEventArgs parameter to the new item. The new object created in the BindingSource.AddingNew event must be of the same type as the type contained in the list or an exception will occur. You cannot set the System.ComponentModel.AddingNewEventArgs.NewObject property when bound to a System.Data.DataView or System.Data.DataTable because you cannot add a new System.Data.DataRowView to the list.

For more information about supplying custom new item functionality, see the BindingSource.AddNew method. For more information about handling events, see Consuming Events.


Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: