Thursday, February 10, 2011

Add and Remove item on comboBox

بسم الله الر حمن الر حيم

          How to add item on comboBox in C#? Please follow me:

  1. Add component of comboBox in Form
  2. Double click header of Form
  3. Type below text (if your comboBox name is comboBox1)
comboBox1.Items.AddRange(new object[] { "String1", "String2", "String3", "String4", "String5" });
comboBox1.Text = "String1";

Or, you can add one of string to your comboBox:


Or, you can load from other component, maybe richTextBox?:

comboBox1.DataSource = richTextBox1.Lines;


          And, how to remove item on comboBox in C#? Please follow me:

To remove one item of list:

// To remove item with index 0:
// To remove currently selected item:
// To remove "" item:

To remove all item on list, use:


Alhamdulillah, Hopefully helpful,,,

No comments:

Post a Comment