ListBox.ObjectCollection.AddRange Method (ListBox.ObjectCollection)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Adds the items of an existing ListBox.ObjectCollection to the list of items in a ListBox.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public void AddRange(
	ListBox.ObjectCollection value


Type: System.Windows.Forms.ListBox.ObjectCollection

A ListBox.ObjectCollection to load into this collection.

If the Sorted property of the ListBox is set to true, the items are inserted into the list alphabetically. Otherwise, the items are inserted in the order that they occur within the array. This method is typically passed an array of String objects, but an array of any type of object can be passed to this method. When an object is added to the collection, the ListBox first checks to see if the DisplayMember property of the ListControl class has the name of a member from the object specified to reference when obtaining the item text. If the DisplayMember property does not have a member specified, the ListBox then calls the ToString method of the object to obtain the text to display in the list.

When using this method to add items to the ListBox, you do not need to call the BeginUpdate and EndUpdate methods to optimize performance. When adding items to a ListBox, it is more efficient to sort the items first and then add new items. You can use this method to reuse the items stored in a different ListBox.

.NET Framework
Available since 1.1
Return to top