Link to home
Start Free TrialLog in
Avatar of Anthony Matovu
Anthony MatovuFlag for Uganda

asked on

populating a combobox

I have 5 comboboxes where by the items in the second combobox depend on the section in the first one, the third depends on the second, and so on.

Challenge i have is when i make the first selection all the file get populated with the first element

below is the example of the code i use. this is a windows application for vb.net


     Try
            dadp = New OleDb.OleDbDataAdapter("SELECT * FROM [villageUnit] WHERE ((([country])= '" & cmbcountry.SelectedValue & "'));", db)
            dT = New DataTable : dadp.Fill(dT) : dadp.Dispose()
            vu.DataSource = dT
            vu.DisplayMember = "villageName" : vu.ValueMember = "vid"
            vu.BindingContext = New BindingContext : vu.SelectedIndex = -1
            Me.hhcode.Text = ""
        Catch inv As InvalidCastException

        Catch ex As Exception

Anthony
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>Challenge i have is when i make the first selection all the file get populated with the first element

Not sure what you mean by that.
Avatar of Anthony Matovu

ASKER

sorry its is

Challenge i have is when i make the first selection all the five  comboboxes get populated with the first element/item
When you make selection in first combobox, all other comboboxes get populated? What is vu? Do you have a single selecteditemchanged handler for all comboboxes?
vu is the name of the second combobox that gets populated after an item from the first combo has been selected. all other comboboxes are populated like that.

I think i dont understand what single selecteditemchanged handler means, but these are comboboxes

Thanks

Anthony
have you read my article? it is dedicated to relational combo
Can you show the full code where the above code is?