Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

cant get the value of combobox

$
0
0

Hi,

I have the following form onload event to populate my combobox:

 ComboBox1.Items.Add(New ValueDescriptionPair(1, "test1"))
        ComboBox1.Items.Add(New ValueDescriptionPair(2, "test2"))
        ComboBox1.Items.Add(New ValueDescriptionPair(3, "test3"))

 I can get the text  of the selected item of the combobox:

ComboBox1.SelectedText.ToString

But I can't get the value of the selected item

ComboBox1.SelectedValue.ToString

and here is my class:

Public Class ValueDescriptionPair

    Public Value As Object
    Public Description As String

    Public Sub New(ByVal NewValue As Object, ByVal NewDescription As String)
        Value = NewValue
        Description = NewDescription
    End Sub

    Public Overrides Function ToString() As String
        Return Description
    End Function

End Class

what am I doing wrong?

Thanks


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>