Surendra Sharma

Surendra Sharma

Search This Blog

Tuesday, July 27, 2010

Add or Remove items from windows Combobox

public class ComboBoxItem

{

  
    private string display;

    private object data;

   
    public ComboBoxItem(string display, object data)


    {

      this.display = display;

      this.data = data;

    }

   
    public override string ToString()


    {

      return display;

    }


}





private
void Form1_Load(object sender, EventArgs e)

{

    comboBox1.Items.Add(new ComboBoxItem("a", 1));


    comboBox1.Items.Add(new ComboBoxItem("b", 2));

    comboBox1.Items.Add(new ComboBoxItem("c", 3));

    comboBox1.Items.Add(new ComboBoxItem("d", 4));

}

private void button1_Click(object sender, EventArgs e)


{

    comboBox1.Items.RemoveAt(2);

}

No comments:

Post a Comment