G
Guest
I have used the following code, but I can't find how to get the SetSelection
property to select the items in the listbox (lstTeams). I'm using C#. When
the checkbox is selected, I want to select all items in lstTeams (90 items)
so the user doesn't have to manually select each item:
private void chkAllTeams_CheckedChanged(object sender, System.EventArgs e)
{
//If the user selects "Select All Teams" checkbox, highlight (select all
items).
lstTeams.SelectionMode=ListSelectionMode.Multiple;
// Loop through all items the ListBox (lstTeams).
for (int x = 0; x < lstTeams.Items.Count; x++)
{
lstTeams.SelectedIndex = x;
}
}
It only select the last item.
property to select the items in the listbox (lstTeams). I'm using C#. When
the checkbox is selected, I want to select all items in lstTeams (90 items)
so the user doesn't have to manually select each item:
private void chkAllTeams_CheckedChanged(object sender, System.EventArgs e)
{
//If the user selects "Select All Teams" checkbox, highlight (select all
items).
lstTeams.SelectionMode=ListSelectionMode.Multiple;
// Loop through all items the ListBox (lstTeams).
for (int x = 0; x < lstTeams.Items.Count; x++)
{
lstTeams.SelectedIndex = x;
}
}
It only select the last item.