Occurs before an item is added to the underlying list.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The event occurs before a new object is added to the underlying list represented by the List property. This event is fired after the 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 BindingSource class. 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 event must be of the same type as the type contained in the list or an exception will occur. You cannot set the NewObject property when bound to a DataView or DataTable because you cannot add a new DataRowView to the list.
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 event handler. This code example is part of a larger example provided in How to: Customize Item Addition with the Windows Forms BindingSource.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.