okaymy1112
Member
- Joined
- Feb 27, 2019
- Messages
- 8
- Programming Experience
- 1-3
My code for The following code for AdditionalStaffEmailListBox_SelectedIndexChanged listbox is not allowing me to select more than one item from the listbox.
How do I change it so I am able to select as many items from the listbox as I want?
How do I change it so I am able to select as many items from the listbox as I want?
C#:
private void AdditionalStaffEmailListBox_SelectedIndexChanged(object sender, EventArgs e)
{
AdditionalStaffEmailListBox = new ListBox();
AdditionalStaffEmailListBox.SelectionMode = SelectionMode.MultiSimple;
AdditionalStaffEmailListBox.BeginUpdate();
//Loop through all items in the AdditionalStaffEmailListBox
for (int x = 0; x < AdditionalStaffEmailListBox.Items.Count; x++)
{
//AdditionalStaffEmailListBox.Items.Add("Item " + x.ToString());
if (AdditionalStaffEmailListBox.GetSelected(x) == true)
{
//Deselect all items that are selected
AdditionalStaffEmailListBox.SetSelected(x, false);
}
else
{
//Select all items that are not selected
AdditionalStaffEmailListBox.SetSelected(x, true);
}
}
//Force the AdditionalStaffEmailListBox to scroll back to the top of the list
AdditionalStaffEmailListBox.TopIndex = 0;
}