You can use a simple LINQ query
var checked_boxes = yourControl.Controls.OfType<CheckBox>().Where(c => c.Checked);
where yourControl is the control containing your checkboxes.
checked_boxes now an object that implements the IEnumerable<CheckBox> that represents the request. Usually you want to foreach over this query using the foreach :
foreach(CheckBox cbx in checked_boxes) { }
You can also convert this query to a list ( List<Checkbox> ) by calling .ToList() , either on checked_boxes, or immediately after Where(...) .
Since you want to combine the Text checkboxes into one string, you can use String.Join .
var checked_texts = yourControl.Controls.OfType<CheckBox>() .Where(c => c.Checked) .OrderBy(c => c.Text) .Select(c => c.Text); var allCheckedAsString = String.Join("", checked_texts);
I also added an OrderBy clause to make sure the checkboxes are sorted by their Text .
source share