How to add new items to ComboBox in C# WinForms

Created: 11/06/2013 12:54:12 p.m.

How to add items to our combobox very easy in .Net (C#)

1) First we need to add a combobox to our WinForm, name comboBox1
2) Second in c# code create a class that will our custom combobox item like this:

    public class ComboBoxItem
        public string Value;
        public string Text;

        public ComboBoxItem(string val, string text)
            Value = val;
            Text = text;

        public override string ToString()
            return Text;

3) And finally add some items to our myCombo:

        private void Form1_Load(object sender, EventArgs e)
           // Add item
            comboBox1.Items.Add(new ComboBoxItem("item1 text", "item1 value"));

            // Show item

Remember to puth the custom class after the main clase (public partial class Form1 : Form)

Result: this will show the first item value.

Thanks for reading.


User: Jim Comment date: 21/08/2013 02:00:04 a.m.
User: Quincy Comment date: 24/12/2013 03:32:07 a.m.

database binding with combobox  c# combobox binding


User: name Comment date: 27/08/2014 09:50:56 a.m.
User: Wholesale Jerseys Cheap Comment date: 21/11/2017 05:29:05 p.m.
4. Anytime your self contain their birthday and anniversary dates, on your own can ship them e mail and reminders, which will guidance your small business be thing to consider of inside a further personable direction.Along with providing a unique opportunity to visit locations throughout the United States, travel nursing careers expose professionals to a variety of practices, philosophies, and experiences that would not be possible in any other circumstances. In short, it has become tedious to convince the customer base. It will provide with spray machines and hand painting. Wholesale Jerseys Cheap

Go to Comments