다음을 통해 공유


방법: Windows Forms ComboBox, ListBox 또는 CheckedListBox 컨트롤의 특정 항목에 액세스

Windows Forms 콤보 상자, 목록 상자 또는 선택 목록 상자에서 특정 항목에 액세스하는 것은 필수 작업입니다. 이 기능을 사용하면 지정된 위치에서 목록에 있는 항목을 프로그래밍 방식으로 확인할 수 있습니다.

특정 항목에 액세스하려면

  1. 특정 항목의 인덱스를 사용하여 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());
       }
    

참고하십시오