How do I bind a ComboBox so the displaymember is concat of 2 fields of source datatable?

后端 未结 7 2005
既然无缘
既然无缘 2020-12-01 18:03

I\'d like to bind a ComboBox to a DataTable (I cannot alter its original schema)

cbo.DataSource = tbldata;
cbo.DataTextField = \"Na         


        
7条回答
  •  感动是毒
    2020-12-01 18:25

    The easiest way is to create a new calculated column in the DataTable, using the Expression property :

    tbldata.Columns.Add("FullName", typeof(string), "Name + ' ' + Surname");
    ...
    cbo.DataTextField = "FullName";
    

提交回复
热议问题