.NET Framework Class Library
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)
Syntax

Visual Basic (Declaration)
Public ReadOnly Property Items As ComboBox..::.ObjectCollection
Visual Basic (Usage)
Dim instance As ComboBox
Dim value As ComboBox..::.ObjectCollection

value = instance.Items
C#
public ComboBox..::.ObjectCollection Items { get; }
Visual C++
public:
property ComboBox..::.ObjectCollection^ Items {
    ComboBox..::.ObjectCollection^ get ();
}
JScript
public function get Items () : ComboBox..::.ObjectCollection
Remarks

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.

Examples

The following code example demonstrates how to add a small number of ComboBox items. If you need to add a large number of items, see the example at BeginUpdate. Both examples are part of a larger example available in the ComboBox class overview.

Visual Basic
Private Sub addButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    comboBox1.Items.Add(textBox1.Text)
End Sub
C#
private void addButton_Click(object sender, System.EventArgs e) {
   comboBox1.Items.Add(textBox1.Text);
}
Visual C++
void addButton_Click( Object^ sender, System::EventArgs^ e )
{
   comboBox1->Items->Add( textBox1->Text );
}
Platforms

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

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0
See Also

Reference

Tags :


Community Content

Thomas Lee
The page for one class should have an list of all its members
Lol, I said "The" page. Unfortunately there are a million pages for each class. Fine, let there be one asp.net.controls.comobox and one windowsforms.combobox page, but not one page for a class's "overview" one for the actual content, another for its member functions, another for its properties.
Tags : complaint

Page view tracker