ComboBox.Items Property

Gets an object representing the collection of the items contained in this ComboBox.

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

[LocalizableAttribute(true)] 
public:
property ObjectCollection^ Items {
	ObjectCollection^ get ();
}
/** @property */
public ObjectCollection get_Items ()

public function get Items () : ObjectCollection

Not applicable.

Property Value

A System.Windows.Forms.ComboBox.ObjectCollection representing the items in the ComboBox.

This property enables you to obtain a reference to the list of items that are currently stored in the ComboBox. With this reference, you can add items, remove items, and obtain a count of the items in the collection.

Although the ComboBox is typically used to display text items, you can add any object to the ComboBox. Typically, the representation of an object in the ComboBox is the string returned by that object's ToString method. If you want to have a member of the object displayed instead, choose the member that will be displayed by setting the DisplayMember property to the name of the appropriate member. You can also choose a member of the object that will represent the value returned by the object by setting the ValueMember property. For more information, see ListControl.

For more information about the tasks that can be performed with the item collection, see the System.Windows.Forms.ComboBox.ObjectCollection class reference topics.

The following code example demonstrates the retrieval of ComboBox items. This example is part of a larger example available in the ComboBox class overview.

void addButton_Click( Object^ sender, System::EventArgs^ e )
{
   comboBox1->Items->Add( textBox1->Text );
}

private void addButton_Click(Object sender, System.EventArgs e)
{
    comboBox1.get_Items().Add(textBox1.get_Text());
} //addButton_Click

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, 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: