Hello, I've just recently gotten back into VB. I am currently developing a Database for a sort of hobby project, and I am having trouble with displaying it properly.

Here is my situation. I have a ComboBox which allows a user to select from a series of categories. Each category shares a name with a specific table in the DB. When the category is selected, the list of items in my Name column populates into a ListBox on the same Form. It took me a little to get this working right, but it is now.

I also have some TextBoxes that will display the information from my other columns in them, based on the SelectedItem from the ListBox. This is where I am running into an issue. I can't set the DataBindings from the start, because then I can only bind to a single table. I am trying to get it to change which table the TextBoxes are bound to based on which category is selected in the original ComboBox.

I was able to get one to bind correctly, but... it only shows the first row in the column (in this instance, the Name again, same as the listbox). I can't seem to find a way to get it to link to the DataSet and to recognize which item is selected in the ListBox.

Any help would be appreciated, and if you need my code (as sparse as it is atm) just let me know :)

After browsing around some other threads, I determined that it would be better if I include my code here :D

The refreshCategory() is called from the cmbCategory on a selecteditem change event.

Private Sub refreshCategory()

        Select Case cmbCategory.SelectedItem

            Case "Regions"

                Call loadRegion()

            Case "Areas"

                Call loadArea()

            Case "Factions"

                Call loadFaction()

        End Select

    End Sub

    Private Sub loadRegion()

        lstCategory.DataSource = bndRegion
        lstCategory.DisplayMember = "RegionName"

        lblName.DataBindings.Clear()
        lblName.DataBindings.Add("Text", AoD_DBDataSet._Region, "RegionName")

    End Sub

    Private Sub loadArea()

        lstCategory.DataSource = bndArea
        lstCategory.DisplayMember = "AreaName"

        lblName.DataBindings.Clear()
        lblName.DataBindings.Add("Text", AoD_DBDataSet.Area, "AreaName")

    End Sub

    Private Sub loadFaction()

        lstCategory.DataSource = bndFaction
        lstCategory.DisplayMember = "FactionName"

        lblName.DataBindings.Clear()
        lblName.DataBindings.Add("Text", AoD_DBDataSet.Faction, "FactionName")

    End Sub

Everything is working correctly, except that I can't tell the Labels (which replaced the TextBoxes in the original post) Binding Source to change which item it is displaying based on what is selected in the lstCategory.

Thanks again in advance :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.