Ckeck / UnCheck All Items in CheckedListbox control in windows application

Hi, here we will learn how to check / uncheck all items from checkdlistbox control by clicking button in windows forms application.

we will learn it with an example in windows form application.

First, design the windows form like below, tack one CheckedListbox control along with two linkbutton for checked and unchecked checkedlistbox control.

CheckedListbox control in windows forms application.
Check / Uncheck CheckedListbox control in windows forms application.

Here, we have two link button for Check all items form CheckedListbox and Unchecked all items from CheckedListbox control in windows forms application.

when we click button ALL then all the items in checkedlistbox will be checked / selected.

write below code in ALL button click event for Checkde all items in Checkedlistbox control.

private void lnkALL_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
for (int i = 0; i < checkedListBox1.Items.Count; i++)
{
checkedListBox1.SetItemChecked(i, true);
}
}

For Uncheckd all items in Checkedlistbox control click NONE button.

write below code in NONE button click event for unchecked all items in checkedlistbox control.

private void lnkNONE_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
for (int i = 0; i < checkedListBox1.Items.Count; i++)
{
checkedListBox1.SetItemChecked(i, false);
}
}

CheckedListbox control in windows application.
Check / Uncheck CheckedListbox control in windows forms application.
Check / Uncheck CheckedListbox control in windows forms application.

I hope, this chekced / unchecked checkedlistbox control will help you…..

Leave a Reply

Your email address will not be published. Required fields are marked *