Results 1 to 2 of 2

Thread: Combobox not updating

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2015

    Combobox not updating


    I have filled a combobox with a column from a database table. I've added some code to update a label when the combobox is changed. The label updates as expected but the combobox never changes to what I've selected - instead just continues displayingt the first item in it. I'm sure its something really simple that I've missed but I just cant see it. I've listed the code below & if anyone can see whats wrong I'd be very grateful.

    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
    Dim sitem = TryCast(ComboBox1.SelectedItem, DataRowView)
    Dim filename As String
    Dim con As New OleDb.OleDbConnection
    Dim dbprovider As String
    Dim dbsource As String
    Dim sql As String
    Dim ds As New DataSet
    Dim da As OleDb.OleDbDataAdapter
    Dim maxrows As Integer
    Dim inc As Integer
    PictureBox1.ImageLocation = ("G:\Psy Game Launcher\Icon\black.png")
    dbprovider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
    dbsource = "Data Source = G:/Psy Game Launcher/PSY Data.mdb"
    con.ConnectionString = dbprovider & dbsource
    sql = "SELECT * FROM Systems"
    da = New OleDb.OleDbDataAdapter(sql, con)
    da.Fill(ds, "AllSystems")
    maxrows = ds.Tables("AllSystems").Rows.Count
    ComboBox1.DisplayMember = "System"
    ComboBox1.DataSource = ds.Tables("AllSystems")
    'ComboBox1.Text = sitem.Row("System").ToString()
    Label12.Text = sitem.Row("Manufacturer").ToString()
    End Sub

    ** EDIT **
    Forget it - I worked it out - sorry !
    Last edited by Psyman; Jan 24th, 2015 at 10:31 AM.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Sydney, Australia

    Re: Combobox not updating

    Firstly, when you're posting code snippets, please format them for readability, i.e.

    []your code here[/highlight]


    [code]your code here[/code]

    Most importantly, that will keep the indenting when you copy and paste from the IDE so it remains much easier to read.

    Secondly, if you solve your own problem then it is considered good form to actually provide the solution so that it might help others with a similar problem in future. It might also be that your solution is not optimal and we can provide something better.

    Finally, if your issue has been resolved then please use the Thread Tools menu to mark it so, so that we don't waste our time reading threads that don't need our attention.

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