In the app I'm working on, I need to maintain a list of Projects which are currently loaded, and display the names of each one in a ListBox (okay, multiple ListBoxes, but that's neither here nor there).
class Project
{
public String Name;
// Etc. etc...
}
I've got a BindingList object which contains all of the loaded Projects, and am binding it to my ListBox(es).
private BindingList<Project> project_list = new BindingList<Project>();
private ListBox project_listbox;
private void setList()
{
project_listbox.DisplayMember = "Name";
project_listbox.ValueMember = "Name";
project_listbox.DataSource = project_list;
}
However when I do this, all that gets displayed in project_listbox
is a set of the class names for the Project. Am I missing something here? Every reference that I could find regarding binding Lists to a ListBox uses a very similar setup.