Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I feel really dumb asking this question but...

I am using a combobox after the selection is changed the first time, I try to change the selection and my method does not get invoked. I'm unsure of what I'm doing wrong.

names.SelectedIndexChanged += delegate
            {
                if (btn.Name.StartsWith("1"))
                    ptsValue = 100;
                else if (btn.Name.StartsWith("2"))
                    ptsValue = 200;
                else if (btn.Name.StartsWith("3"))
                    ptsValue = 300;
                else if (btn.Name.StartsWith("4"))
                    ptsValue = 400;
                else if (btn.Name.StartsWith("5"))
                    ptsValue = 500;
                else
                    ptsValue = 600;

                int score = 0;

                for (int i = 0; i < NamesFLC; i++)
                {

                    if (String.Compare(tableofNames[i], (string)names.SelectedItem, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        score = tableofPoints[i];
                        score += ptsValue;
                        tableofPoints[i] = score;
                    }
                }
                QuestionBox.Controls.Remove(names);
                QuestionBox.Controls.Remove(cls);
                QuestionBox.Controls.Remove(question);
                this.Controls.Remove(btn);
                QuestionBox.Close();
            };


What I'm after is being able to change the selection and this being invoked EVERY time. Is there a way to reset the control such that after it's changed the first time it will acknowledge the next change? Thank you for all your help
Posted

1 solution

Do autopostback=true; for the combobox
 
Share this answer
 
Comments
Dalek Dave 29-Nov-10 17:51pm    
Spot on.
MrNiceBerG 29-Nov-10 22:49pm    
Thank you for your help, didn't work for me because I wasn't using a web.form. I was writting a program for a desktop. I solved my issue though, thank you VERY MUCH for your help, it pointed me in the right direction.
M_AhsanRiaz 30-Nov-10 7:01am    
Ok,That's good.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900