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:
When I select an item in the combo & click the button I get a value of 0, no matter which item I select.Code:Dim tmp As Integer = CInt(Me.ComboBox1.SelectedValue)
If I select "Short" in the combobox it should return 25000. What am I doing wrong?




Reply With Quote