Export (0) Print
Expand All
2 out of 15 rated this helpful - Rate this topic

How to: Access Specific Items in a Windows Forms ComboBox, ListBox, or CheckedListBox Control 

Accessing specific items in a Windows Forms combo box, list box, or checked list box is an essential task. It enables you to programmatically determine what is in a list, at any given position.

To access a specific item

  • Query the Items collection using the index of the specific item:

    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());
       }
    

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.