This documentation is archived and is not being maintained.

ComboBox.ObjectCollection.Insert Method

Inserts an item into the collection at the specified index.

[Visual Basic]
Public Overridable Sub Insert( _
   ByVal index As Integer, _
   ByVal item As Object _
) Implements IList.Insert
[C#]
public virtual void Insert(
 int index,
 object item
);
[C++]
public: virtual void Insert(
 int index,
 Object* item
);
[JScript]
public function Insert(
   index : int,
 item : Object
);

Parameters

index
The zero-based index location where the item is inserted.
item
An object representing the item to insert.

Return Value

The zero-based index of the newly added item.

Implements

IList.Insert

Exceptions

Exception Type Condition
ArgumentNullException The item was a null reference (Nothing in Visual Basic).
ArgumentOutOfRangeException The index was less than zero.

-or-

The index was greater than the count of items in the collection.

Remarks

If the sorted property of the ComboBox is true, the index parameter is ignored. When an object is added to the collection, the ComboBox calls the object's ToString method is to obtain the string to display in the list.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

ComboBox.ObjectCollection Class | ComboBox.ObjectCollection Members | System.Windows.Forms Namespace

Show: