如何:在 Windows Form 的 ComboBox、ListBox 或 CheckedListBox 控制項中存取特定的項目
存取 Windows Forms 下拉式方塊、清單方塊或核取方塊中的特定專案是一項基本工作。 它可讓您以程式設計方式判斷清單中位於任何指定位置的內容。
存取特定專案
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()); }
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應