samedi 14 octobre 2017

c# - Set checkboxes to checked when adding to listview, best way?

Trying to figure out the best way to set the default state of checkboxes to checked when adding them to a list view. I have the following code, and am guessing that I need to add a statement in the foreach loop to set the default status to checked, but I cant figure it out

checkBoxAddCities = checkBoxAddCities.Distinct().ToList();
        ColumnHeader columnCities = new ColumnHeader();
        columnCities.Text = "Cities";
        columnCities.Name = "columnCities";
        columnCities.Width = listViewCities.Width - 21;
        listViewCities.Columns.Add(columnCities);
        foreach (var s in checkBoxAddCities)
        {
            listViewCities.Items.Add(s.ToString());                
        }




Aucun commentaire:

Enregistrer un commentaire