Adding Items to ListBox and ComboBox Controls

by Shabbir on May 10, 2008

in C#

Adding items to this controls in .Net is very easy. To demonstrate that we will create a simple project with the following controls:

  • ListBox (name: listBox1)
  • ComboBox (name: comboBox1)
  • TextBox (name: textBox1)
  • Button (text: Add)

So, drag this controls from the toolbox and drop them on the main form one by one. Make a form like this

List box and combo box

Now double click on the button, it will create a button click event. Insert this code there

listBox1.Items.Add(textBox1.Text);
comboBox1.Items.Add(textBox1.Text);
textBox1.Clear();

Now, write something in the text box and then click the button. The text you entered in the textBox1 will be inserted as item in the listBox1 and comboBox1, and the textBox1 text will be cleared.

List box and combo box with data

Sharing is Caring...

Other Related Posts:

  1. Adding Items to ListView Control
  2. ASP.Net Web Site Sample
  3. Creating a Windows Forms Application in C#
  4. Simple Data Entry In Microsoft Access Database
  5. Creating a Database Connection

Leave a Comment

Spam protection by WP Captcha-Free

Previous post:

Next post:

    About the Author

  • author photo

    My Name is Shabbir Bhimani and I am developer by profession in the field of applications, web and database. Currently doing full time online marketing and like to share my experiences on how you can make money online @ CodeItWell.com. Read more ...


    See how you can get in touch with me.