Search code examples
c#mysqlsqlcombobox

How can I delete all the items in combo box?


I have a ComboBox control with the DropDownStyle properties set to DropDownList. I want to replace the list of items with some new items at some points in the form but it concatenates the new items with the old items. How can I delete the old items and place new items in the combo box?

I am trying something like that:

        this.selectAttribute.Items.AddRange(new object[] {
            "Airport_Name", //New items
            "City",
            "Country"});


Solution

  • You could try clearing the items first:

    this.selectAttribute.Items.Clear();