AddingNewEventArgs.NewObject Property (System.ComponentModel)

Switch View :
ScriptFree
.NET Framework Class Library
AddingNewEventArgs.NewObject Property

Gets or sets the object to be added to the binding list.

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

Visual Basic
Public Property NewObject As Object
	Get
	Set
C#
public Object NewObject { get; set; }
Visual C++
public:
property Object^ NewObject {
	Object^ get ();
	void set (Object^ value);
}
F#
member NewObject : Object with get, set

Property Value

Type: System.Object
The Object to be added as a new item to the associated collection.
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 default constructor, and then adding it to the 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.

Visual Basic

' 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


C#

// This event handler provides custom item-creation behavior.
void customersBindingSource_AddingNew(
    object sender, 
    AddingNewEventArgs e)
{
    e.NewObject = DemoCustomer.CreateNewCustomer();
}


Visual C++

// This event handler provides custom item-creation behavior.
void OnCustomersBindingSourceAddingNew(Object^ sender, 
    AddingNewEventArgs^ e)
{
    e->NewObject = DemoCustomer::CreateNewCustomer();
}


Version Information

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Reference