Cannot bind to the new display member in ComboBox

后端 未结 9 752
迷失自我
迷失自我 2021-01-01 21:14

I have a class which give me this error

public class Item 
{
    public string Name;
    public int Id

    public Item(string name, int id) 
    {
        N         


        
9条回答
  •  南笙
    南笙 (楼主)
    2021-01-01 21:22

    You can either check datasource null or bind datasource after setting value member and display member

            cmbDepartment.DisplayMember = "Dep_Name";
            cmbDepartment.ValueMember = "Dep_ID";
            cmbDepartment.DataSource = model;
    

提交回复
热议问题