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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. ComboBox Problem

ComboBox Problem

Scheduled Pinned Locked Moved C#
helptutorialquestionannouncement
5 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.
  • D Offline
    D Offline
    Darren D
    wrote on last edited by
    #1

    Hi, I have a combobox with a dropdownstyle of DropDown. I have my DataSource and DisplayMember set up in the combobox properties like so: DataSource = bindingSourceFollowUpCodes DisplayMember = Legend ValueMember = FollowUpCode I have tried to set the properties to update correctly but I can't figure out how to do it. I have searched all over for an answer. I can do this properly in code. Could someone see if they can figure out what the correct property setting s would be to do this without code? protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Get Groups list CommandGetFollowUpCodes getFollowUpCodes = new CommandGetFollowUpCodes("%"); m_FollowUpCodes = (FollowUpCodeList)m_AppController.ExecuteCommand(getFollowUpCodes); // Bind controls bindingSourceFollowUpCodes.DataSource = m_FollowUpCodes; comboBoxFollowUpCode.SelectedItem = null; GroupItem itmGroup = (GroupItem)bindingSourceDefault.Current; foreach (FollowUpCodeItem itmFollowUpCode in m_FollowUpCodes) { if (itmGroup.FollowUpCode == itmFollowUpCode.FollowUpCode) { comboBoxFollowUpCode.SelectedItem = itmFollowUpCode; } } } private void comboBoxFollowUpCode_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxFollowUpCode.SelectedItem != null) { GroupItem itmGroup = (GroupItem)bindingSourceDefault.Current; FollowUpCodeItem itmFollowUpCode = (FollowUpCodeItem)comboBoxFollowUpCode.SelectedItem; itmGroup.FollowUpCode = itmFollowUpCode.FollowUpCode; } } Thanks, Darren

    C 1 Reply Last reply
    0
    • D Darren D

      Hi, I have a combobox with a dropdownstyle of DropDown. I have my DataSource and DisplayMember set up in the combobox properties like so: DataSource = bindingSourceFollowUpCodes DisplayMember = Legend ValueMember = FollowUpCode I have tried to set the properties to update correctly but I can't figure out how to do it. I have searched all over for an answer. I can do this properly in code. Could someone see if they can figure out what the correct property setting s would be to do this without code? protected override void OnLoad(EventArgs e) { base.OnLoad(e); // Get Groups list CommandGetFollowUpCodes getFollowUpCodes = new CommandGetFollowUpCodes("%"); m_FollowUpCodes = (FollowUpCodeList)m_AppController.ExecuteCommand(getFollowUpCodes); // Bind controls bindingSourceFollowUpCodes.DataSource = m_FollowUpCodes; comboBoxFollowUpCode.SelectedItem = null; GroupItem itmGroup = (GroupItem)bindingSourceDefault.Current; foreach (FollowUpCodeItem itmFollowUpCode in m_FollowUpCodes) { if (itmGroup.FollowUpCode == itmFollowUpCode.FollowUpCode) { comboBoxFollowUpCode.SelectedItem = itmFollowUpCode; } } } private void comboBoxFollowUpCode_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxFollowUpCode.SelectedItem != null) { GroupItem itmGroup = (GroupItem)bindingSourceDefault.Current; FollowUpCodeItem itmFollowUpCode = (FollowUpCodeItem)comboBoxFollowUpCode.SelectedItem; itmGroup.FollowUpCode = itmFollowUpCode.FollowUpCode; } } Thanks, Darren

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Darren D wrote:

      DisplayMember = Legend ValueMember = FollowUpCode

      These are variables that contain the names you want ?

      Darren D wrote:

      what the correct property setting s would be to do this without code?

      Why are people so obsessed with codeless 'programming' nowadays ? I don't think you can link combo boxes in the designer so it works this out for itself.

      Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

      D 1 Reply Last reply
      0
      • C Christian Graus

        Darren D wrote:

        DisplayMember = Legend ValueMember = FollowUpCode

        These are variables that contain the names you want ?

        Darren D wrote:

        what the correct property setting s would be to do this without code?

        Why are people so obsessed with codeless 'programming' nowadays ? I don't think you can link combo boxes in the designer so it works this out for itself.

        Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

        D Offline
        D Offline
        Darren D
        wrote on last edited by
        #3

        Legend and FollowUpCode are the field names. The list is working fine. I don't seem to be able to bind the property that stores the target of the lookup table. If I bind it then the first item from the list shows up every time I load the form. I can select a value from the list but it never saves. The code I wrote works fine. There should be a way to do this without code I am just not getting it. 'Codeless' programs have less bugs I think. DD

        D 1 Reply Last reply
        0
        • D Darren D

          Legend and FollowUpCode are the field names. The list is working fine. I don't seem to be able to bind the property that stores the target of the lookup table. If I bind it then the first item from the list shows up every time I load the form. I can select a value from the list but it never saves. The code I wrote works fine. There should be a way to do this without code I am just not getting it. 'Codeless' programs have less bugs I think. DD

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Darren D wrote:

          There should be a way to do this without code I am just not getting it.

          No, there isn't. How is this "codeless" engine suppose to know wht you want if you put two ComboBox's on a form? Are they supposed to be independant or each other or is one list suppsoed to change with the item picked in the other? There's no way to tell.

          Darren D wrote:

          'Codeless' programs have less bugs I think.

          They sure do! But this is because there is also no application when you have no code stitching the controls together, not to mention how the business rules work, or the data storage, ...

          Dave Kreskowiak Microsoft MVP - Visual Basic

          D 1 Reply Last reply
          0
          • D Dave Kreskowiak

            Darren D wrote:

            There should be a way to do this without code I am just not getting it.

            No, there isn't. How is this "codeless" engine suppose to know wht you want if you put two ComboBox's on a form? Are they supposed to be independant or each other or is one list suppsoed to change with the item picked in the other? There's no way to tell.

            Darren D wrote:

            'Codeless' programs have less bugs I think.

            They sure do! But this is because there is also no application when you have no code stitching the controls together, not to mention how the business rules work, or the data storage, ...

            Dave Kreskowiak Microsoft MVP - Visual Basic

            D Offline
            D Offline
            Darren D
            wrote on last edited by
            #5

            Well...I could do this in VB6. Why can't I do it in C#? I am just setting properties on the combobox for everything but saving whatever the user picked from the list. It's not really "codeless." This is just my "View." There will be business rule code in the Model. DD

            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