In this article, I will discus about how can we add a Select All checkbox in our Windows Forms, So that when we check or uncheck that checkbox, all the checkboxes present in his group got checked or unchecked automatically. By default, no such functionality is present in Visual Studio. So we have to create an extra checkbox which will do the work for us. And if you want this kind of functionality, then I will recommend you to use CheckedListBox in place of just checkboxes.
Instructions:
- Open the Windows form, in which you want to add a Select All checkbox.
- From toolbox add CheckedListBox into your Form.
- Click on the “Small Arrow” pointing toward right in the CheckedListBox and select “Edit Items…”.
- Enter the options you want to have in CheckedListBox, but you must add “Select All” option at the top.
- Click Ok and then open Properties Window for this CheckedListBox. In the Properties Window, click on Events icon and then double click on SelectedIndexChanged event.
- This will create an event function for this event. Now add the following code in the newly created function
if (checkedListBox1.SelectedIndex == 0)
{
for (int i = 1; i < checkedListBox1.Items.Count; i++)
{
checkedListBox1.SetItemChecked(i, checkedListBox1.GetItemChecked(0));
}
}
else
{
if (!checkedListBox1.GetItemChecked(checkedListBox1.SelectedIndex))
{
checkedListBox1.SetItemChecked(0, false);
}
}

Incoming search terms:
- c# windows form check and uncheck select all for a group of checkboxes (1)
- checked item in a checkboxlist an print it in a textbox in windows form c sharp visual studio 2008 (1)
- disable all checkboxes in visual studio (1)
- F4550 c# (1)
- inurl:how make ip spoofing in c# (1)
- Visual studio 2010 c# checkedlistbox (1)