insert object into comboBox
I want to insert an object into comboBox in Win C#, I have 3 items in object. This is my code
List<me开发者_如何学运维t>dyo = new List<met>();
dyo=DAL.metpa();
foreach(met t in dyo )
{
comboBox1.DataSource = d;
comboBox1.DisplayMember = t.last_Name;
comboBox1.ValueMember = t.id_Metp;
}
and I got this error:
Cannot bind to the new display member.Parameter name: newDisplayMember
What is the problem?
Try
List<met>dyo = new List<met>(); dyo=DAL.metpa();
foreach(met t in dyo )
{
comboBox1.DataSource = d;
comboBox1.DisplayMember = "last_Name"
comboBox1.ValueMember = "id_Metp";
}
精彩评论