Results 1 to 10 of 10

Thread: Setting & getting Combobox value member

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    Setting & getting Combobox value member

    I'm trying to populate a combobox in code with values as follows:

    Code:
            Me.ComboBox1.Items.Add(New KeyValuePair(Of String, Integer)("Quick", 10000))
            Me.ComboBox1.Items.Add(New KeyValuePair(Of String, Integer)("Short", 25000))
            Me.ComboBox1.Items.Add(New KeyValuePair(Of String, Integer)("Medium", 50000))
            Me.ComboBox1.Items.Add(New KeyValuePair(Of String, Integer)("Long", 100000))
            Me.ComboBox1.DisplayMember = "Key"
            Me.ComboBox1.ValueMember = "Value"

    And then to get the value I'm doing this in a button click event:

    Code:
     Dim tmp As Integer = CInt(Me.ComboBox1.SelectedValue)
    When I select an item in the combo & click the button I get a value of 0, no matter which item I select.
    If I select "Short" in the combobox it should return 25000. What am I doing wrong?
    Last edited by nbrege; Jan 1st, 2024 at 10:03 AM.

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