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()
.
More Related Contents:
- Databinding to List – See changes of data source in ListBox, ComboBox
- Complex UI inside ListBoxItem
- Get the value for a listbox item by index
- Background color of a ListBox item (Windows Forms)
- C#: How to add subitems in ListView
- How to bind Dictionary to ListBox in WinForms
- Bind multiple ComboBox to a single List – Issue: When I select an item, all combo boxes change
- How to change ListBox selection background color?
- Getting value of selected item in list box as string
- How can I set different Tooltip text for each item in a listbox?
- WPF Filter a ListBox
- Winforms DotNet ListBox items to word wrap if content string width is bigger than ListBox width?
- Playing a MP3 file in a WinForm application
- WPF Binding a ListBox to an enum, displaying the Description Attribute
- How can I treat the circle as a control after drawing it? – Moving and selecting shapes
- Zoom and translate an Image from the mouse location
- How to initialize a list of strings (List) with many string values
- Set TabPage Header Color
- How can I sort a List by multiple T.attributes?
- How to Draw a Rounded Rectangle with WinForms (.NET)?
- Get the SourceControl of a DropDownMenu
- Save Settings in VB.Net or C#
- How to add event handler for dynamically created controls at runtime?
- Control.AddRange(…) is slow
- TLS 1.2 not negotiated in .NET 4.7 without explicit ServicePointManager.SecurityProtocol call
- Order of events ‘Form.Load’, ‘Form.Shown’ and ‘Form.Activated’ in Windows Forms
- Popup window in winform c#
- big issue in converting string to datetime using linq-to-entities
- Is it possible to switch rows and columns in a datagridview?
- How to set a text box for inputing password in winforms?