What is the proper way to load a ListBox in C# .NET 2.0 Winforms?
I thought I could just bind it to a DataTable. No such luck.
I though
Lets assume your data type is called MyDataType. Implement ToString() on that datatype to determine the display text. e.g.:
class MyDataType
{
public string ToString()
{
//return the text you want to display
}
}
Then you can take a list consisting of your datatype and cram it into the ListBox via AddRange() as follows:
ListBox l;
List myItems = new List(); // populate this however you like
l.AddRange(myItems.ToArray());
Let me know if you need more help - it would help to know what datatype you are trying to display in the listbox.