none
How to I fix listbox to display items and not collection? RRS feed

  • Question

  • My code to populate a listbox is not working. Instead of the 15 items inside requestors being populated, the listbox instead shows <b>collection</b>.
    How do I fix this so that the 15 items inside requestors = requestors.OrderBy(x => x.DisplayName).ToList(); are displayed on the listbox.

    public async void PopulateAdditionalStaffEmailListBox()

    {

    List<GetRequestorInfoModel> requestors = new List<GetRequestorInfoModel>(); try { requestors = await FTACaseReset.Controllers.RequestorInfoController.GetAllRequestorInfoes();        requestors = requestors.OrderBy(x => x.DisplayName).ToList(); //Has 15 items but they are not displayed in the listbox        AdditionalStaffEmailListBox.Items.Add(requestors); } catch (Exception ex) { string errorMsg = string.Format("An error has occured in {0}. \nException:\n{1}", "AdditionalStaffEmailListBox()", ex.Message); MessageBox.Show(errorMsg, "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Error);} }



    • Edited by winkimjr2 Wednesday, June 26, 2019 7:42 PM
    Wednesday, June 26, 2019 7:41 PM

All replies