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

How to use combobox in C#

JesuSingarayar
on
Medium Priority
1,997 Views
Last Modified: 2013-12-14
Hi experts,
I am beginner, i want to use combobox in C# application.I just want to choose a single item from a combobox list and assign it to a variable X...

Say for example
If(item in the list is IPADD)
X = IPADD;


How do i do that?
Thanks for your help.
Tony

Comment
Watch Question

1) ComboBox is different from listbox, you can only choose one item;
2) if you want get the select item you need to add a handler to IndexChaged event; something like this:
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (-1 != this.comboBox1.SelectedIndex)
            {
                ListItem oItem = (ListItem)this.comboBox1.SelectedItem;
                //this.comboBox1.Text = oItem.Text;
            }

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

Ask the Experts
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.