Binding two comboboxes in WPF
-
Hi all Im trying to bind two comboboxes together. I have a table called country and a table called city in SQL database. When a user selects a country in the countrycombox i want it to filter the cities that are in that country and show them on the city Combobox. Can some one help me please. Thanks in advance
-
Hi all Im trying to bind two comboboxes together. I have a table called country and a table called city in SQL database. When a user selects a country in the countrycombox i want it to filter the cities that are in that country and show them on the city Combobox. Can some one help me please. Thanks in advance
hello dear, you can add one column in country table and one coulmn in city table the name of column may be "ExamineId" in both ethe tables then in country table put integer value(1,2,3,4,5.....) for every country in "ExamineId" column.and put the corresponding number for cities in city table. like in country table ExamineId country 1 country1 2 country2 in city table ExamineId city country 1 abc country1 1 xyz country1 1 wpg country1 2 ghf country2 2 yhk country2 2 poi country2 select ExaminId from country table for selectes country and take it in one string type variable say "EId". then make query for combobox2 as select * from city where ExamineId = EId and put all the data in combobox2. hope it'll help u.... :laugh: sandy
-
hello dear, you can add one column in country table and one coulmn in city table the name of column may be "ExamineId" in both ethe tables then in country table put integer value(1,2,3,4,5.....) for every country in "ExamineId" column.and put the corresponding number for cities in city table. like in country table ExamineId country 1 country1 2 country2 in city table ExamineId city country 1 abc country1 1 xyz country1 1 wpg country1 2 ghf country2 2 yhk country2 2 poi country2 select ExaminId from country table for selectes country and take it in one string type variable say "EId". then make query for combobox2 as select * from city where ExamineId = EId and put all the data in combobox2. hope it'll help u.... :laugh: sandy
-
Hi all Im trying to bind two comboboxes together. I have a table called country and a table called city in SQL database. When a user selects a country in the countrycombox i want it to filter the cities that are in that country and show them on the city Combobox. Can some one help me please. Thanks in advance
This is the general logic:
<StackPanel Orientation="Horizontal" DataContext="{Binding Source={StaticResource mySource}}">
<ComboBox ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True" />
<ComboBox ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True" />
</StackPanel>Obviously, you need to put your binding source into the context, and the paths you want to work with (plus any item templates you see fit), but this should get you started.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
-
hello dear, you can add one column in country table and one coulmn in city table the name of column may be "ExamineId" in both ethe tables then in country table put integer value(1,2,3,4,5.....) for every country in "ExamineId" column.and put the corresponding number for cities in city table. like in country table ExamineId country 1 country1 2 country2 in city table ExamineId city country 1 abc country1 1 xyz country1 1 wpg country1 2 ghf country2 2 yhk country2 2 poi country2 select ExaminId from country table for selectes country and take it in one string type variable say "EId". then make query for combobox2 as select * from city where ExamineId = EId and put all the data in combobox2. hope it'll help u.... :laugh: sandy
This seems a ridiculous idea to solve this kind of problem- "Changing backend to render UI" !! Crazy!!! This should be very simple one...You better do a "Google" with the search keyword- "IsSynchronizeCurrentItem in WPF" rather changing the database schema.
sdixit110 wrote:
you can add one column in country table and one coulmn in city table the name of column may be "ExamineId" in both
I am wondering how people find solutions like this...BAD SOLUTIONS!!!
Moim Hossain R&D Project Manager BlueCielo ECM Solutions BV
-
This seems a ridiculous idea to solve this kind of problem- "Changing backend to render UI" !! Crazy!!! This should be very simple one...You better do a "Google" with the search keyword- "IsSynchronizeCurrentItem in WPF" rather changing the database schema.
sdixit110 wrote:
you can add one column in country table and one coulmn in city table the name of column may be "ExamineId" in both
I am wondering how people find solutions like this...BAD SOLUTIONS!!!
Moim Hossain R&D Project Manager BlueCielo ECM Solutions BV
Well said. +5.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith