ComboBox.Items 属性

获取一个对象,该对象表示该 ComboBox 中所包含项的集合。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
<LocalizableAttribute(True)> _
Public ReadOnly Property Items As ObjectCollection
用法
Dim instance As ComboBox
Dim value As ObjectCollection

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

属性值

表示 ComboBox 中的项的 System.Windows.Forms.ComboBox.ObjectCollection

备注

该属性使您可以获取对当前存储在 ComboBox 中的项列表的引用。通过此引用,可以在集合中添加项、移除项和获得项的计数。有关可对项集合执行的任务的更多信息,请参见 System.Windows.Forms.ComboBox.ObjectCollection 类参考主题。

示例

Private Sub addButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    comboBox1.Items.Add(textBox1.Text)
End Sub
private void addButton_Click(object sender, System.EventArgs e) {
   comboBox1.Items.Add(textBox1.Text);
}
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 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

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

ComboBox 类
ComboBox 成员
System.Windows.Forms 命名空间