Adds a new item to the underlying list.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The method adds a new item to the underlying list represented by the List property. This method sets up the following series of actions:
The EndEdit method is automatically called to commit any pending edit operations.
The AddingNew event is automatically raised. This event can be programmatically handled to construct the new item. This is accomplished in the event handler by setting the NewObject property of the System.ComponentModel.AddingNewEventArgs parameter to the new item. The new object created in the AddingNew event must be of the same type as the type contained in the list or an exception will occur.
If the AddingNew event is not handled, and the underlying list is an IBindingList, then the request is passed to the list's IBindingList.AddNew method. If the underlying list is not an IBindingList, the item is automatically created through its public default constructor. In either case, the new item is added to the end of the list.
The new item is added immediately to the internal list unless the data source implements the IEditableObject interface. In this case, the new item is not committed until an explicit call to ICancelAddNew.EndNew is made or until a new list operation is initiated. Before it is committed, the new item can be rolled back by calling CancelEdit, in which case the new item is discarded.
This method raises the ListChanged event.
The following code example uses a BindingSource component to bind a list to a DataGridView control. New items are added to the list by the AddingNew event handler. This code example is part of a larger example provided in How to: Customize Item Addition with the Windows Forms BindingSource.