Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Binding two comboboxes in WPF

Binding two comboboxes in WPF

Scheduled Pinned Locked Moved WPF
databasewpfcsharpwcfhelp
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    boiDev
    wrote on last edited by
    #1

    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

    S P 2 Replies Last reply
    0
    • B boiDev

      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

      S Offline
      S Offline
      sdixit110
      wrote on last edited by
      #2

      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

      B M 2 Replies Last reply
      0
      • S sdixit110

        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

        B Offline
        B Offline
        boiDev
        wrote on last edited by
        #3

        thank you :-D

        1 Reply Last reply
        0
        • B boiDev

          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

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          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

          My blog | My articles | MoXAML PowerToys

          1 Reply Last reply
          0
          • S sdixit110

            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

            M Offline
            M Offline
            Moim Hossain
            wrote on last edited by
            #5

            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

            P 1 Reply Last reply
            0
            • M Moim Hossain

              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

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              Well said. +5.

              "WPF has many lovers. It's a veritable porn star!" - Josh Smith

              My blog | My articles | MoXAML PowerToys

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups