بسم الله الر حمن الر حيم
How to add item on comboBox in C#? Please follow me:
- Add component of comboBox in Form
- Double click header of Form
- 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:
comboBox1.Items.Add("http://alfatikhul.blogspot.com");
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:
comboBox1.Items.RemoveAt(0);
// To remove currently selected item:
comboBox1.Items.Remove(comboBox1.SelectedItem);
// To remove "http://alfatikhul.blogspot.com" item:
comboBox1.Items.Remove("http://alfatikhul.blogspot.com");
To remove all item on list, use:
listBox1.Items.Clear();
Alhamdulillah, Hopefully helpful,,,
No comments:
Post a Comment