Results 1 to 6 of 6

Thread: Combo Box

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Posts
    303
    I am using a combobox with 8 items in it.
    How do I know which item the user has selected, i.e.,
    combo1.listindex is 0 even tho the user has already
    select something.

    Thanks for the help.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    combo1.text
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    Addicted Member
    Join Date
    Feb 2001
    Location
    Classified
    Posts
    234
    Private Sub Combo1_Click()
    Label1.Caption = Combo1.Text
    End Sub

    Private Sub Form_Load()
    Combo1.AddItem "One", 0
    Combo1.AddItem "Two", 1
    Combo1.AddItem "Three", 2
    Combo1.AddItem "Four", 3
    Combo1.AddItem "Five", 4
    Combo1.AddItem "Six", 5
    Combo1.AddItem "Seven", 6
    Combo1.Text = "One"
    End Sub
    My ICQ Status: (85634850)

    Seriously Sick Tshirts

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Posts
    303
    Hi Cander,

    Sorry for not being clear. What I really want is the
    index of the combo item and not the text because
    I have another object that I must match the index
    of the combo box to.

    Example:

    cboItems(0).text = "APPLE" cboPrice(0).text = "$1.4"
    cboItems(1).text = "PEAR" cboPrice(1).text = "$1.0"
    cboItems(2).text = "PIE" cboPrice(2).text = "$0.4"

    So when the user selected "PEAR" I want to read
    the value from cboPrice(1).text

  5. #5
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    oh..my bad..
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Posts
    303
    found the answer/problem:

    Answer: use the cboItems_click()
    cboItems.ListIndex

    Problem: cboItems_Change()
    will return -1 for cboItems.ListIndex

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