Binding Listbox to List<object> in WinForms

cam picture cam · Apr 20, 2010 · Viewed 169.2k times · Source

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

Answer

SLaks picture SLaks · Apr 20, 2010

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().