Export (0) Print
Expand All

BindingList<T>.AddingNew Event

Occurs before an item is added to the list.

Namespace:  System.ComponentModel
Assembly:  System (in System.dll)

public event AddingNewEventHandler AddingNew

The AddingNew event occurs before a new object is added to the collection represented by the Items property. This event is raised after the AddNew method is called, but before the new item is created and added to the internal list. By handling this event, the programmer can provide custom item creation and insertion behavior without being forced to derive from the BindingList<T> class.

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 demonstrates how to handle the AddingNew event. For the complete example, see the BindingList<T> class overview topic.

// Create a new part from the text in the two text boxes. 
void listOfParts_AddingNew(object sender, AddingNewEventArgs e)
{
    e.NewObject = new Part(textBox1.Text, int.Parse(textBox2.Text));

}

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, Xbox 360, Zune

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.

.NET Framework

Supported in: 3.5, 3.0, 2.0

.NET Compact Framework

Supported in: 3.5, 2.0

XNA Framework

Supported in: 3.0, 2.0, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft