Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

link 2 combo box

Status
Not open for further replies.

deulyd

Programmer
Oct 17, 2001
106
CA
Hi,
I have 2 combo box in a form. One containing countries and the second contains the provinces. I populate data by setting their datasource property to a table in my dataset. My dataset contains the appropriate relations.

Now, How can I link those 2 combo box in the form? With databinding property? How?

Thanks

Deulyd

 
Use a Dataview to filter out only the provinces for the selected country. Then set the 2nd combos datasource to the dataview. The code supplied will need amending to suit, and could be placed in the validated event of the country combo

Code:
dim dv As DataView = dtProvinces.DefaultView
dv.RowFilter = "country_id=" &  combocountry.ValueMember.tostring
comboProvince.DataSource = dv
comboProvince.DisplayMember = "province_name"
comboProvince.ValueMember = "province_id"



Sweep
...if it works dont mess with it
 
Isn't there a way to do that without using a dataView? Only by using the dataRelation between the tables?
 
I believe you use syntax like the following:

ParentTable.RelationName.

Look up this article in help: "Walkthrough: Creating a Master-Detail Windows Form"
 
Its an article in help in VS.Net 2002. I don't know if it is 2003. I'm sure you can find it on MSDN as well.
 
Still can't figure out what how to link the 2 combo box (Parent-Child) with that example...

Can you please give me some code of how to do that; please.

Thanks

Deulyd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top