访问 Windows 窗体组合框、列表框或选中列表框中的特定项是一项基本任务。 它使你能够以编程方式确定列表中的内容(在任何给定位置)。
访问特定项
通过特定项的索引查询
Items
集合。Private Function GetItemText(i As Integer) As String ' Return the text of the item using the index: Return ComboBox1.Items(i).ToString End Function
private string GetItemText(int i) { // Return the text of the item using the index: return (comboBox1.Items[i].ToString()); }
private: String^ GetItemText(int i) { // Return the text of the item using the index: return (comboBox1->Items->Item[i]->ToString()); }