none
How do I change my combo box to ListBox to allow user select more than one name RRS feed

  • Question

  • 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.

    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);
                }
            }




    • Edited by winkimjr2 Thursday, June 20, 2019 2:16 PM No responses
    Friday, June 7, 2019 1:58 PM