I am trying to bind a generic list like List Parents to a ComboBox.
public Form1()
{
InitializeComponent();
List<Parent> parents = new List<Parent>();
Parent p = new Parent();
p.child = new Child();
p.child.DisplayMember="SHOW THIS";
p.child.ValueMember = 666;
parents.Add(p);
comboBox1.DisplayMember = "child.DisplayMember";
comboBox1.ValueMember = "child.ValueMember";
comboBox1.DataSource = parents;
}
}
public class Parent
{
public Child child { get; set; }
}
public class Child
{
public string DisplayMember { get; set; }
public int ValueMember { get; set; }
}
When I run my test app I only see: "ComboBindingToListTest.Parent" displayed in my ComboBox instead of "SHOW THIS". How can I bind a ComboBox to a Generic List through one level or deeper properties e.g. child.DisplayMember??
Thanks in Advance, Adolfo