Click here to Skip to main content
15,906,626 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi how to Apply for each loop to checkedbox list in windows form Application in visual studio 2012
Im using C#
Posted
Comments
BillWoodruff 17-Feb-14 6:29am    
Unless you tell us what you mean by "apply," you will only get guesses in response.

Refer this demo code block


XML
List<ListItem> selected = new List<ListItem>();
foreach (ListItem item in CBLGold.Items)
    if (item.Selected) selected.Add(item);
 
Share this answer
 
Not clear that much.

But, if you are talking about a simple List<checkbox> then,

C#
List<CheckBox> cbList = new List<CheckBox>();

foreach(CheckBox cb in cbList)
{
    //do what you want here.

    cb.Checked = true;
}



Regards.
 
Share this answer
 
Look at the Items Property[^]:
C#
foreach (object o in myCheckedListBox.Items)
    {
    Console.WriteLine(o.ToString());
    }
Or use the CheckedItems Property[^] instead.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900