AddingNewEventArgs.NewObject Property
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.
Gets or sets the object to be added to the binding list.
public:
property System::Object ^ NewObject { System::Object ^ get(); void set(System::Object ^ value); };
public object NewObject { get; set; }
public object? NewObject { get; set; }
member this.NewObject : obj with get, set
Public Property NewObject As Object
Property Value
The Object to be added as a new item to the associated collection.
Examples
The following code example demonstrates how to use the AddingNewEventArgs class to handle the BindingSource.AddingNew event. This code example is part of a larger example provided in How to: Customize Item Addition with the Windows Forms BindingSource.
// This event handler provides custom item-creation behavior.
void OnCustomersBindingSourceAddingNew(Object^ sender,
AddingNewEventArgs^ e)
{
e->NewObject = DemoCustomer::CreateNewCustomer();
}
// This event handler provides custom item-creation behavior.
void customersBindingSource_AddingNew(
object sender,
AddingNewEventArgs e)
{
e.NewObject = DemoCustomer.CreateNewCustomer();
}
' This event handler provides custom item-creation behavior.
Private Sub customersBindingSource_AddingNew( _
ByVal sender As Object, _
ByVal e As AddingNewEventArgs) _
Handles customersBindingSource.AddingNew
e.NewObject = DemoCustomer.CreateNewCustomer()
End Sub
Remarks
If the NewObject property is set to null
, it indicates that the collection is to take the standard action, which typically entails creating an object of the appropriate type using its parameterless constructor, and then adding it to the collection.