C# Add ITem To ComboBox

How To Add Value To A Combobox Using C# 

add item to a combobox

In This C# Tutorial  We Will See How To Insert Values Into A ComboBox From TextBox Or Another ComboBox On Button Click In CSharp Programming Language And Visual Studio Editor.


Project Source Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class AddValToCombo : Form
    {
        public AddValToCombo()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            comboBox1.Items.Insert(0, textBox1.Text);

            comboBox1.Items.Add(comboBox2.SelectedItem);

            comboBox1.SelectedIndex = 0;

        }
    }
}

      
///////////////OUTPUT:





add itemes to combo using csharp



Share this

Related Posts

Previous
Next Post »