Wednesday, 22 May 2013

C# How to use ComboBox in C#




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 box
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            comboBox1.Items.Add("bashir ahmed khan");
            comboBox1.Items.Add("umar javed");
        }

        private void cmdSet_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == 0)
            {
                textBox1.Text = "bashir ahmed khan";
            }
            if (comboBox1.SelectedIndex == 1)
            {
                textBox1.Text = "Umarjaved";
            }
        }
    }
}

No comments:

Post a Comment