This documentation is archived and is not being maintained.

BindingSource.AddingNew Event

Note: This event is new in the .NET Framework version 2.0.

Occurs before an item is added to the underlying list.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in

public event AddingNewEventHandler AddingNew
/** @event */
public void add_AddingNew (AddingNewEventHandler value)

/** @event */
public void remove_AddingNew (AddingNewEventHandler value)

JScript supports the use of events, but not the declaration of new ones.

Exception typeCondition


NewObject is not the same type as the type contained in the list.

The AddingNew 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 AddingNew 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.

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

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.

public Form1()
    // Set up the form.
    this.Size = new Size(800, 800);
    this.Load += new EventHandler(Form1_Load);

    // Set up the DataGridView control.
    this.customersDataGridView.Dock = DockStyle.Fill;

    // Attach an event handler for the AddingNew event.
    this.customersBindingSource.AddingNew += 
        new AddingNewEventHandler(customersBindingSource_AddingNew);

    // Attach an event handler for the ListChanged event.
    this.customersBindingSource.ListChanged += 
        new ListChangedEventHandler(customersBindingSource_ListChanged);

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

.NET Compact Framework

Supported in: 2.0