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. C#
  4. WinForms Comboboxes

WinForms Comboboxes

Scheduled Pinned Locked Moved C#
questioncsharpwinforms
3 Posts 3 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.
  • I Offline
    I Offline
    Illegal Operation
    wrote on last edited by
    #1

    Hi, I have two comboboxes, cbPhysicalCountry and cbPostalCountry. Both Comboboxes are populated via a dataset. How can I set the cbPostalCountry = cbPhysicalCountry when the user checks the checkbox "UsePhysicalCountry"? I populate my comboboxes with the following code

    DataSet dsPhysicalCountry = WCFService.GetCountry();

    cbPhysicalCountry.DataSource = dsPhysicalCountry.Tables["Country"];
    cbPhysicalCountry.DisplayMember = "Country";
    cbPhysicalCountry.ValueMember = "Id";

    When the checkbox_checkchanged event fires I have the following code,

    if(checkbox.checked == true)
    {
    cbPostalCountry.SelectedItem = cbPhysicalCountry.SelectedItem;
    }

    Thank you in advance...

    Illegal Operation

    D M 2 Replies Last reply
    0
    • I Illegal Operation

      Hi, I have two comboboxes, cbPhysicalCountry and cbPostalCountry. Both Comboboxes are populated via a dataset. How can I set the cbPostalCountry = cbPhysicalCountry when the user checks the checkbox "UsePhysicalCountry"? I populate my comboboxes with the following code

      DataSet dsPhysicalCountry = WCFService.GetCountry();

      cbPhysicalCountry.DataSource = dsPhysicalCountry.Tables["Country"];
      cbPhysicalCountry.DisplayMember = "Country";
      cbPhysicalCountry.ValueMember = "Id";

      When the checkbox_checkchanged event fires I have the following code,

      if(checkbox.checked == true)
      {
      cbPostalCountry.SelectedItem = cbPhysicalCountry.SelectedItem;
      }

      Thank you in advance...

      Illegal Operation

      D Offline
      D Offline
      dotnetmember
      wrote on last edited by
      #2

      try this way, if (checkBox1.Checked == true) cbPostalCountry.SelectedValue= cbPhysicalCountry.SelectedValue;

      1 Reply Last reply
      0
      • I Illegal Operation

        Hi, I have two comboboxes, cbPhysicalCountry and cbPostalCountry. Both Comboboxes are populated via a dataset. How can I set the cbPostalCountry = cbPhysicalCountry when the user checks the checkbox "UsePhysicalCountry"? I populate my comboboxes with the following code

        DataSet dsPhysicalCountry = WCFService.GetCountry();

        cbPhysicalCountry.DataSource = dsPhysicalCountry.Tables["Country"];
        cbPhysicalCountry.DisplayMember = "Country";
        cbPhysicalCountry.ValueMember = "Id";

        When the checkbox_checkchanged event fires I have the following code,

        if(checkbox.checked == true)
        {
        cbPostalCountry.SelectedItem = cbPhysicalCountry.SelectedItem;
        }

        Thank you in advance...

        Illegal Operation

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        What happens if the postal and physical countries are different? Try SelectedValue instead of item. Try using a BindingSource instead of a table.

        Never underestimate the power of human stupidity RAH

        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