AllowNew Property

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)

public:
property bool AllowNew {
	bool get();
	void set(bool value);
}

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
Available since 2.0
Return to top
Show:
© 2016 Microsoft