Click here to Skip to main content
16,017,235 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to checked all items in CheckedListBox when i check other checbox take below in the CheckedListBox?
Posted
Comments
[no name] 12-May-14 9:14am    
You have not read the FAQ for hints on how to ask a question yet have you?
Peter Leow 12-May-14 9:34am    
Tag your question properly, winform or asp.net?

This is for winform:
C#
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
    for (int i = 0; i < checkedListBox1.Items.Count; i++)
    {
        checkedListBox1.SetItemChecked(i, checkBox1.Checked);
    }
}
 
Share this answer
 
v2
Refer this link :

Check Uncheck all items in ASPNet CheckBoxList using jQuery

or below code snippet :

C#
protected void cbExtList_OnSelectedIndexChanged(object sender, EventArgs e)
{
    try
    {
        if (Convert.ToInt32(this.cbExtList.SelectedItem.Value) == 0)
        {
            foreach (ListItem li in cbExtList.Items)
            {
                li.Selected = true;
            }
        }
        else
        {
            foreach (ListItem li in cbExtList.Items)
            {
                li.Selected = false;
            }
        }
    }
    catch (Exception ex)
    {
        Monitoring.WriteException(ex);
    }
}
 
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