G
GS
I got a combobox box that I load at load time. the Item and vales ended up
in reverse order of each other, what went wrong?
the database table has the following row
code value
ebay http://www.ebay.com
google http://www.google.com
yahoo http://www.yahoo.com
However in the drop down list
displayed value used
ebay http://www.yahoo.com
google http://www.google.com
yahoo http://www.google.com
here is the code listing for populating the combobox
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim Conn As New SqlConnection("Data
source=.\SQLEXPRESS;AttachDbFileName=C:\myCtl.mdf;Integrated
Security=True;Connect TimeOut=30;User Instance=True")
Using Conn
Dim queryString As String = "select code, value as Addr from
dbo.CodeTable where (codeTableName = 'FinCoUrl') And (sequence > 0) order by
sequence"
Dim adapter As New SqlDataAdapter()
adapter.SelectCommand = New SqlCommand(queryString, Conn)
Dim datatable As New DataTable
adapter.Fill(datatable)
addressBar.DataSource = datatable.DefaultView
addressBar.DisplayMember = "code"
addressBar.ValueMember = "Addr"
End Using
WidthaddressBar = addressBar.Width
End Sub
the above code worked with a combox in another application . the only
diffference is the name
Is there some property on the combo I need to fix ?
in reverse order of each other, what went wrong?
the database table has the following row
code value
ebay http://www.ebay.com
google http://www.google.com
yahoo http://www.yahoo.com
However in the drop down list
displayed value used
ebay http://www.yahoo.com
google http://www.google.com
yahoo http://www.google.com
here is the code listing for populating the combobox
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim Conn As New SqlConnection("Data
source=.\SQLEXPRESS;AttachDbFileName=C:\myCtl.mdf;Integrated
Security=True;Connect TimeOut=30;User Instance=True")
Using Conn
Dim queryString As String = "select code, value as Addr from
dbo.CodeTable where (codeTableName = 'FinCoUrl') And (sequence > 0) order by
sequence"
Dim adapter As New SqlDataAdapter()
adapter.SelectCommand = New SqlCommand(queryString, Conn)
Dim datatable As New DataTable
adapter.Fill(datatable)
addressBar.DataSource = datatable.DefaultView
addressBar.DisplayMember = "code"
addressBar.ValueMember = "Addr"
End Using
WidthaddressBar = addressBar.Width
End Sub
the above code worked with a combox in another application . the only
diffference is the name
Is there some property on the combo I need to fix ?