Results 1 to 2 of 2

Thread: How to select the first item of a DropDownList Combobox

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2012
    Posts
    21

    How to select the first item of a DropDownList Combobox

    I have a combo box with four lines of data:

    Code:
    Reina Beatrix Arpt, Aruba, AW (AUA)
    Grantley Adams Intl Arpt, Barbados, BB (BGI)
    Owen Roberts Arpt, Grand Cayman Island, KY (GCM)
    Miami Intl, Miami, FL (MIA)
    Cyril E King Arpt, St Thomas, VI (STT)

    I want to write a program where I select the first item of a DropDownList Combo box (or the second, third, forth, and fifth item) and write an if... end if statement to specify a certain condition.

    This doesn't work
    Code:
    If Combobox1.Items.Items(0) Then
    TextBox1.Text = ....
    End if
    Thank you!

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: How to select the first item of a DropDownList Combobox

    use the selectedindex, + selecteditem, or text properties of your combobox

    the selectedindex ranges from -1 (no item selected) to items.count -1 (the last item)
    the text is what is displayed in the non dropdown part of your combobox

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width