Search code examples
c#winformsc#-4.0combobox

Refresh ComboBox Items, easiest way


I've googled a lot. Found a lot as well. Unfortunately nothing is straight, easy and most importantly, simple. I want some guy write a method that takes a List<string> and removes previous Items, then set this List<string>.

Currently I have a method but it's not error free.

public void refreshList(List<string> list){
    albumList.Items.Clear();
    albumList.DataSource =  list;
}

Solution

  • You don't need albumList.Items.Clear();

    This code works just fine

    public void refreshList(List<string> list){
        albumList.DataSource =  list;
    }