locked
Object as binding source for ComboBox WinForms RRS feed

  • Question

  • Hallo

    I'm a bit lost, not sure why I cannot get this to display correct. 

    We get some data from SQL database into a list of Objects. (Below screenshot of one of the objects and will be populated at a later stage with more then just this one as a List of objects.

    I need bind the PrimKey to value member and Username to DisplayMember, but it seems to be a issue, I cannot get the Combobox to display correctly..Easy question, but looking at google is a bit confusing.

           private void PopulateUserNameCombobox()
            {            
                int rowCounter = 0;
    
                cmbUsername.DataSource = currentUsers;
    
                foreach (var item in currentUsers)
    
                    if (currentUsers[rowCounter].Status == 0)
                   {                  
                        cmbUsername.ValueMember = currentUsers[rowCounter].UserID.ToString();
                        cmbUsername.DisplayMember = currentUsers[rowCounter].UserName.ToString();
                    }            
            }


    labjac

    • Moved by Dave PatrickMVP Thursday, August 13, 2020 11:49 PM looking for forum
    Thursday, August 13, 2020 11:14 PM

Answers