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. combo box on a windows form

combo box on a windows form

Scheduled Pinned Locked Moved C#
helpcareer
7 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.
  • S Offline
    S Offline
    sea
    wrote on last edited by
    #1

    I'm trying to use a combo box on a windows form which will change its display on event of changing combo selection. This is the method I wrote:

    private void SurveyChooserCombo_SelectedIndexChanged(object sender, EventArgs e)
    		{
    			DAL dal = new DAL();
    			switch (SurveyChooserCombo.SelectedIndex)
    			{
    				case 0:
    					SrNo = 1;
    					break;
    					
    				case 1:
    					SrNo = 2;
    					break;
    
    				case 2:
    					SrNo = 3;
    					break;
    				default:
                       SrNo = 3;
    					break;
    			}
    

    It doesn't do the job. Please help me find why. TIA, sea#

    J L J 3 Replies Last reply
    0
    • S sea

      I'm trying to use a combo box on a windows form which will change its display on event of changing combo selection. This is the method I wrote:

      private void SurveyChooserCombo_SelectedIndexChanged(object sender, EventArgs e)
      		{
      			DAL dal = new DAL();
      			switch (SurveyChooserCombo.SelectedIndex)
      			{
      				case 0:
      					SrNo = 1;
      					break;
      					
      				case 1:
      					SrNo = 2;
      					break;
      
      				case 2:
      					SrNo = 3;
      					break;
      				default:
                         SrNo = 3;
      					break;
      			}
      

      It doesn't do the job. Please help me find why. TIA, sea#

      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #2

      What is SrNo? What do you want to change in the combo box?

      Tech, life, family, faith: Give me a visit. I'm currently blogging about: Homosexuality in Christianity Judah Himango

      1 Reply Last reply
      0
      • S sea

        I'm trying to use a combo box on a windows form which will change its display on event of changing combo selection. This is the method I wrote:

        private void SurveyChooserCombo_SelectedIndexChanged(object sender, EventArgs e)
        		{
        			DAL dal = new DAL();
        			switch (SurveyChooserCombo.SelectedIndex)
        			{
        				case 0:
        					SrNo = 1;
        					break;
        					
        				case 1:
        					SrNo = 2;
        					break;
        
        				case 2:
        					SrNo = 3;
        					break;
        				default:
                           SrNo = 3;
        					break;
        			}
        

        It doesn't do the job. Please help me find why. TIA, sea#

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        "doesn't do the job" is very vague, what doesn't work in particular?

        S 1 Reply Last reply
        0
        • L Lost User

          "doesn't do the job" is very vague, what doesn't work in particular?

          S Offline
          S Offline
          sea
          wrote on last edited by
          #4

          SrNo, which is an int represents survey no. Each time I change the item in combo, it is changed. "doesn't do the job" means SurveyChooserCombo.SelectedIndex seems to be left unchanged. When I run the application the form doesn't change the display as expected. Also cannot run it in debug mode, as I get "there is no source code available for current location", when trying to run over method more then once- to make the change in index come true. sea#

          1 Reply Last reply
          0
          • S sea

            I'm trying to use a combo box on a windows form which will change its display on event of changing combo selection. This is the method I wrote:

            private void SurveyChooserCombo_SelectedIndexChanged(object sender, EventArgs e)
            		{
            			DAL dal = new DAL();
            			switch (SurveyChooserCombo.SelectedIndex)
            			{
            				case 0:
            					SrNo = 1;
            					break;
            					
            				case 1:
            					SrNo = 2;
            					break;
            
            				case 2:
            					SrNo = 3;
            					break;
            				default:
                               SrNo = 3;
            					break;
            			}
            

            It doesn't do the job. Please help me find why. TIA, sea#

            J Offline
            J Offline
            Jano Petras
            wrote on last edited by
            #5

            Are you sure you have added event handler? i.e. comboBox.SelectedIndexChanged+=new SelectionChangeHandler(<>) ??? This is done automatically by Visual Designer - simply naming method SurveyChooserCombo_SelectedIndexChanged does not automatically associate it with the control... - Another possibility is that the event may not be fired if combo box list style is not a selection from drop-down list but a mixture of type-in and select from the list... Hope this helps. Regards JP

            S 1 Reply Last reply
            0
            • J Jano Petras

              Are you sure you have added event handler? i.e. comboBox.SelectedIndexChanged+=new SelectionChangeHandler(<>) ??? This is done automatically by Visual Designer - simply naming method SurveyChooserCombo_SelectedIndexChanged does not automatically associate it with the control... - Another possibility is that the event may not be fired if combo box list style is not a selection from drop-down list but a mixture of type-in and select from the list... Hope this helps. Regards JP

              S Offline
              S Offline
              sea
              wrote on last edited by
              #6

              Petras J. wrote: Are you sure you have added event handler? i.e. comboBox.SelectedIndexChanged+=new SelectionChangeHandler(<>) ??? I do have event handler. Petras J. wrote: - Another possibility is that the event may not be fired if combo box list style is not a selection from drop-down list but a mixture of type-in and select from the list... it is just an ordinary drop-down list. Nothing complicated. What else should I do to make it change once selction changed? TIA, sea#

              S 1 Reply Last reply
              0
              • S sea

                Petras J. wrote: Are you sure you have added event handler? i.e. comboBox.SelectedIndexChanged+=new SelectionChangeHandler(<>) ??? I do have event handler. Petras J. wrote: - Another possibility is that the event may not be fired if combo box list style is not a selection from drop-down list but a mixture of type-in and select from the list... it is just an ordinary drop-down list. Nothing complicated. What else should I do to make it change once selction changed? TIA, sea#

                S Offline
                S Offline
                sea
                wrote on last edited by
                #7

                Wrote this code:

                private void SurveyChooserCombo_SelectedIndexChanged(object sender, EventArgs e)
                {
                if (SurveyChooserCombo.Text.Equals("Survey1"))
                SrNo = 1;
                else if (SurveyChooserCombo.Text.Equals("Survey2"))
                SrNo = 2;
                else if (SurveyChooserCombo.Text.Equals("Survey3"))
                SrNo = 3;
                else
                SrNo = 3;
                GetResults (SrNo);
                }

                stil event is not fired, dsiplay doesnot changed.

                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