Linking Combo Boxes with text boxes independently

venomphil

New member
Joined
May 4, 2013
Messages
2
Programming Experience
Beginner
Hi VB.Net Forums,

I have created a form that references a access database and this works great.

Currently I have a list of products in a combo box and when the user selects the product I want the items price to be displayed in a text box

My problem is when the user selects a different option in the combo boxes, all other combo boxes change - Is there a way to make them independent from each other?

So I have 3 items in 3 different Combo Boxes the prices output in 3 Text boxes

Thanks Phil
 
vb-question.jpg

I want each of these to work independently from each other ^^
 
I'm guessing that you have populated a DataTable and then bound it to all three ComboBoxes. In that case there would only be one CurrencyManager, which is what handles the selection in the UI. You need a separate CurrencyManager for each ComboBox, which means binding a different list to each control. The easiest way to do that is to use BindingSources. Add three BindingSources to your form and bind the DataTable to each of them, then bind one to each ComboBox. You should find that you then get the behaviour you want. You should bind the TextBoxes to the BindingSources too. E.g.
BindingSource1.DataSource = myDataTable

ComboBox1.DisplayMember = "Name"
ComboBox1.ValueyMember = "ID"
ComboBox1.DataSource = BindingSource1

TextBox1.DataBindings.Add("Text", BindingSource1, "Price")
 
Back
Top