Export (0) Print
Expand All

ListBox.ObjectCollection.Insert Method

Inserts an item into the list box at the specified index.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public void Insert (
	int index,
	Object item
)
public final void Insert (
	int index, 
	Object item
)
public final function Insert (
	index : int, 
	item : Object
)
Not applicable.

Parameters

index

The zero-based index location where the item is inserted.

item

An object representing the item to insert.

Exception typeCondition

ArgumentOutOfRangeException

The index parameter is less than zero or greater than value of the Count property of the ListBox.ObjectCollection class.

This method enables you to insert an item at a specific position within the ListBox. If the Sorted property of the ListBox is set to true, the item is added in the correct position within the sorted list regardless of the values specified in the index parameter. 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.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft