Binding Listbox to List<object> in WinForms

c#, list, listbox, winforms

Solution

You're looking for the `DataSource property`:

List<SomeType> someList = ...;
myListBox.DataSource = someList;

You should also set the `DisplayMember` property to the name of a property in the object that you want the listbox to display. If you don't, it will call `ToString()`.

Problem

What's the simplest way to bind a Listbox to a List of objects in Windows Forms?

Original source