Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all

Please tell me how to uncheck the checked value of a CheckedListBox on a button click

thank you
Posted
Comments
Can you show us what have you tried so far ?
[no name] 8-Dec-12 1:45am    
List<checkedlistbox> t3 = new List<checkedlistbox>();
t3.Add(checkedListBox1);


foreach (CheckedListBox chkitem in checkedListBox1.Items)
{
chkitem.SelectedItem = false;
}
This i tried

uncheck all of checked items:
C#
chkitem.ClearSelected();


Uncheck the checked value of a CheckedListBox:
C#
chkitem.SetItemChecked(index, false);


And your code:
C#
foreach (int index in chkitem.CheckedIndices)
{
    chkitem.SetItemChecked(index, false);
}
 
Share this answer
 
Solution 1:

you can try like this also.

checkedListBox1.Items.Add("value1", CheckState.Unchecked);


For better understanding follow this link. CheckBoxList

Solution-2:

Try like this too.

C#
foreach(int i in checkedListBox1.CheckedIndices)
{
    checkedListBox1.SetItemCheckState(i, CheckState.Unchecked);
}




Thanks
 
Share this answer
 
v2
Try this
C#
foreach (ListItem li in chkBoxList.Items) {
   if(li.Selected==true){
             li.Selected=false;
           }
         }
 
Share this answer
 
v2

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