Saturday 3 August 2013

Add Items To Combobox In C# Winforms


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

namespace AddItemsToComboBox
{
    public partial class Form1 : Form
    {
        publicForm1()
        {
            InitializeComponent();
        }

        privatevoid Form1_Load(objectsender, EventArgs e)
        {
            // It Shows The Text On The Combobox On Form Load
            comboBox1.Text = "-Select-";

            //Below Code Shows The Combobox Items Added
            comboBox1.Items.Add("Ramachandra");
            comboBox1.Items.Add("Venkatesh");
            comboBox1.Items.Add("Shakti");
            comboBox1.Items.Add("Kranthi");
            comboBox1.Items.Add("Kasani");
        }
    }
}

Output:-


No comments:

Post a Comment

Note: only a member of this blog may post a comment.