如何让我的列表框允许我 select 多个项目
How do I make my listbox allow me to select more than one item
我需要帮助才能让我的 AdditionalStaffEmailListBox_SelectedIndexChanged 允许我 select 不止一项。现在它只允许我 select 一项。
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;
}
AdditionalStaffEmailListBox.SelectionMode = SelectionMode.MultiExtended;
按住 Ctrl 键然后单击select您想要的。
我需要帮助才能让我的 AdditionalStaffEmailListBox_SelectedIndexChanged 允许我 select 不止一项。现在它只允许我 select 一项。
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;
}
AdditionalStaffEmailListBox.SelectionMode = SelectionMode.MultiExtended;
按住 Ctrl 键然后单击select您想要的。