Export (0) Print
Expand All

ComboBox.ObjectCollection.IList.Add Method

This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.

For a description of this member, see IList.Add.

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

int IList.Add(
	Object item
)

Parameters

item
Type: System.Object

An object that represents the item to add to the collection.

Return Value

Type: System.Int32
The zero-based index of the item in the collection.

Implements

IList.Add(Object)

ExceptionCondition
ArgumentNullException

The item parameter is null.

SystemException

There is insufficient space available to store the new item.

This member is an explicit interface member implementation. It can be used only when the ComboBox.ObjectCollection instance is cast to an IList interface.

This method adds an item to the combo box. If the Sorted property of the ComboBox is set to true, the item is inserted into the list alphabetically. Otherwise, the item is inserted at the end of the list.

A visual representation of the item is displayed in the combo box. This content representation is specified by the DisplayMember property. If the DisplayMember property is null, the item's ToString method is called to obtain the string that is displayed in the combo box; otherwise, the property of the stored object as specified by the DisplayMember property is displayed. To add a set of items to the combo box, it is best to use the AddRange method. If you choose to use the Add method to add a set of items to the combo box, use the BeginUpdate method to suspend repainting during your add and the EndUpdate method to resume repainting. You can use the Insert method to specify the location in the list where an item is added. When an object is added to the collection, the ComboBox calls the object's ToString method to obtain the string to display in the list.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft