开发者

insert object into comboBox

开发者 https://www.devze.com 2023-03-23 07:01 出处:网络
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>();

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";

    }
0

精彩评论

暂无评论...
验证码 换一张
取 消