dcsimg
Results 1 to 6 of 6

Thread: How do I make my combo box allow user select more than one name

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2013
    Posts
    42

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

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,260

    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

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2013
    Posts
    42

    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?

  4. #4
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    5,619

    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.

  5. #5
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    5,619

    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.

  6. #6

    Thread Starter
    Member
    Join Date
    Sep 2013
    Posts
    42

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

    Thanks for your input. I will create a ListBox.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width