3 Replies - 300 Views - Last Post: 10 June 2019 - 07:12 AM Rate Topic: -----

#1 okaymy1112   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 10-June 19

How do I make my combo box allow user select more than one item?

Posted 10 June 2019 - 06:20 AM

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


Is This A Good Question/Topic? 0
  • +

Replies To: How do I make my combo box allow user select more than one item?

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15114
  • View blog
  • Posts: 60,481
  • Joined: 12-June 08

Re: How do I make my combo box allow user select more than one item?

Posted 10 June 2019 - 07:00 AM

I would suggest using a 'checked listbox' instead.
Was This Post Helpful? 1
  • +
  • -

#3 okaymy1112   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 10-June 19

Re: How do I make my combo box allow user select more than one item?

Posted 10 June 2019 - 07:07 AM

View Postmodi123_1, on 10 June 2019 - 07:00 AM, said:

I would suggest using a 'checked listbox' instead.

Is it difficult to change ComboBox to a ListBox?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15114
  • View blog
  • Posts: 60,481
  • Joined: 12-June 08

Re: How do I make my combo box allow user select more than one item?

Posted 10 June 2019 - 07:12 AM

Not particularly. You should try it out.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1