We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Disabling submit button until the user selects something from the drop down

yuvaratna
yuvaratna asked
on
Medium Priority
196 Views
Last Modified: 2013-11-07
I am working on windows application.I have a from where the user can submit it, only if he selects whom he wants to submit the form....i am using combo box here....ant suggestions on how to do this!
Thanks in advance.....
Comment
Watch Question

Top Expert 2013

Commented:
did you try SelectedIndexChanged
private void comboBox1_SelectedIndexChanged(Object sender,  System.EventArgs e)
    {  Submitbtn.Enabled = "false";
}

Author

Commented:
nope! this is not working in the way i wanted! if i set Submitbtn.Enabled = false then the button is being enbabled first time i mean when the form loads and when the  combo box index is changed...it is being disabled!
Top Expert 2013
Commented:
sorry ... i misinterperted...
On formLoad button should be disabled.
Then in SelectedIndexChanged you set it enabled:
Submitbtn.Enabled = "true";

Please share more info or any code ..if you are having any trouble.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Top Expert 2013

Commented:
Sample code:
private void Form1_Load(object sender, EventArgs e)
        {
            btnSubmit.Enabled = false;
            comboBox1.Items.Add("SelectOne");
            comboBox1.Items.Add("one");
            comboBox1.Items.Add("two");
            comboBox1.Items.Add("Three");
            comboBox1.SelectedIndex = 0;
 
        }
 
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex != 0)
            {
                btnSubmit.Enabled = true;
            }
 
        }

Open in new window

Author

Commented:
Thanks a lot!!!!!!!!!!

Give me a min, i ll see if it works the way i wanted.....i am sure it works!!!!!

Author

Commented:
Perfect!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.