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

ListBox.ObjectCollection.AddRange Method (ListBox.ObjectCollection)

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
)

Parameters

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

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft