Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

BindingList(T).AllowNew Property

Gets or sets a value indicating whether you can add items to the list using the AddNew method.

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

member AllowNew : bool with get, set

Property Value

Type: System.Boolean
true if you can add items to the list with the AddNew method; otherwise, false. The default depends on the underlying type contained in the list.

The AllowNew property is typically used by other components to determine if the creation of new items is allowed. AllowNew defaults to true if the type contained in the list has a default constructor or the AddingNew event is handled. If the AddingNew event is not handled or the list type does not have a default constructor, then AllowNew defaults to false.

If AllowNew is explicitly set, the set value will always be used by bound objects to determine if new items can be added to the list. Whether AllowNew is true or false, new items can be added by explicitly calling AddNew if the list type has a default constructor or the AddingNew event is handled. In addition, setting AllowNew causes a ListChanged event of type Reset to occur.

The following code example demonstrates how to set the AllowNew property. For the complete example, see the BindingList(T) class overview topic.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0
© 2015 Microsoft