ComboBox.Items Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets an object representing the collection of the items contained in this ComboBox.
public:
property System::Windows::Forms::ComboBox::ObjectCollection ^ Items { System::Windows::Forms::ComboBox::ObjectCollection ^ get(); };
public System.Windows.Forms.ComboBox.ObjectCollection Items { get; }
member this.Items : System.Windows.Forms.ComboBox.ObjectCollection
Public ReadOnly Property Items As ComboBox.ObjectCollection
A ComboBox.ObjectCollection representing the items in the ComboBox.
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.
void addButton_Click( Object^ sender, System::EventArgs^ e )
{
comboBox1->Items->Add( textBox1->Text );
}
private void addButton_Click(object sender, System.EventArgs e) {
comboBox1.Items.Add(textBox1.Text);
}
Private Sub addButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
comboBox1.Items.Add(textBox1.Text)
End Sub
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.
מוצר | גירסאות |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
משוב של .NET
.NET הוא פרויקט קוד פתוח. בחר קישור כדי לספק משוב: