Problem trying to select all items in listbox

G

Guest

I have used the following code, but I get an error. 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=SelectionMode.MultipleSimple;
// Loop through all items the ListBox (lstTeams).
for (int x = 0; x < lstTeams.Items.Count; x++)
{
lstTeams.SelectedIndex = x;
}
}
The error is: The type or namespace name 'SelectionMode' could not be found
(are you missing a using directive or an assembly reference?)

Is there a using System.? that I need to include to get Listbox property to
display?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top