Im very new to coding and I was wondering if anyone could please tell me how
to select all the items in a listbox when a checkbox is checked, and then
when the checkbox is unchecked to unselected the items in the listbox. Here
is the event I would like to put this into.
private void chkSelectAll_CheckedChanged(object sender,
System.EventArgs e)
{
}
Thank you for any help you can give me
Morten Wennevik - 30 Sep 2004 17:00 GMT
Hi Stephen,
private void chkSelectAll_CheckedChanged(object sender,
System.EventArgs e)
{
for(int i = 0; i < myListBox.Items.Count; i++)
{
myListBox.SetSelected(i, chkSelectAll.Checked);
}
}
Note that unless the ListBox' SelectionMode is set to one of the multi modes you will only see the last item selected.

Signature
Happy coding!
Morten Wennevik [C# MVP]