How do I make my combo box allow user select more than one name
I need help make my Combo Box allow a user to select more than one name (item). How do I do this?
Here is the visual basic code that I need to make changes to.
Code:
public async void PopulateRequestorComboBox()
{
List<GetRequestorInfoModel> requestors = new List<GetRequestorInfoModel>();
RequestorComboBox.Items.Clear();
RequestorUpdateComboBox.Items.Clear();
try
{
requestors = await FTACaseReset.Controllers.RequestorInfoController.GetAllRequestorInfoes();
requestors = requestors.OrderBy(x => x.DisplayName).ToList();
#region Populate RequestorComboBox
ComboboxItem firstRequestor = new ComboboxItem();
firstRequestor.Text = "<-Please select Requestor->";
firstRequestor.Value = 0;
RequestorComboBox.Items.Add(firstRequestor);
for (int i = 0; i < requestors.Count; i++)
{
ComboboxItem item = new ComboboxItem();
item.Text = requestors[i].DisplayName;
item.Value = requestors[i].RequestorInfoID;
RequestorComboBox.Items.Add(item);
}
if (RequestorComboBox.Items.Count > 0)
RequestorComboBox.SelectedIndex = 0;
#endregion
#region Populate RequestorUpdateComboBox
for (int i = 0; i < requestors.Count; i++)
{
ComboboxItem item = new ComboboxItem();
item.Text = requestors[i].DisplayName;
item.Value = requestors[i].RequestorInfoID;
RequestorUpdateComboBox.Items.Add(item);
}
#endregion
}
catch (Exception ex)
{
string errorMsg = string.Format("An error has occured in {0}. \nException:\n{1}", "PopulateRequestorComboBox()", ex.Message);
MessageBox.Show(errorMsg, "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Re: How do I make my combo box allow user select more than one name
Thread moved from the 'CodeBank VB.Net' forum (which is for you to post working code examples, not questions) to the 'VB.Net' forum
Re: How do I make my combo box allow user select more than one name
Sir you removed my question but you did not tell me where to post my question. Can you please tell me where to post my question?
Re: How do I make my combo box allow user select more than one name
The question wasn't removed. It was moved to the VB.Net forum, which is where the question should have been posted.
You don't need to post it again since it has been moved for you.
Re: How do I make my combo box allow user select more than one name
As for the question, the combobox doesn't support multi-selection.
You can write you own custom version of a combobox to implement that if it is really necessary.
But usually, if you want multi-selection you would use a Listbox which supports that feature.
Re: How do I make my combo box allow user select more than one name
Thanks for your input. I will create a ListBox.