BindingList<T>.AddingNew Event
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Occurs before an item is added to the list.
public:
event System::ComponentModel::AddingNewEventHandler ^ AddingNew;
public event System.ComponentModel.AddingNewEventHandler AddingNew;
member this.AddingNew : System.ComponentModel.AddingNewEventHandler
Public Custom Event AddingNew As AddingNewEventHandler
Event Type
Examples
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));
}
' Create a new part from the text in the two text boxes.
Private Sub listOfParts_AddingNew(ByVal sender As Object, _
ByVal e As AddingNewEventArgs) Handles listOfParts.AddingNew
e.NewObject = New Part(textBox1.Text, Integer.Parse(textBox2.Text))
End Sub
Remarks
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 how to handle events, see Handling and Raising Events.