Share via


方法 : Windows フォーム ComboBox、ListBox、または CheckedListBox コントロールの特定の項目にアクセスする

更新 : 2007 年 11 月

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.get_Items().get_Item( i).ToString() ;
    }
    
    private:
       String^ GetItemText(int i)
       {
          // Return the text of the item using the index:
          return (comboBox1->Items->Item[i]->ToString());
       }
    

参照

参照

ComboBox

ListBox

CheckedListBox

その他の技術情報

オプションのリストを表示するための Windows フォーム コントロール