转自原文 C#中ListBox的Items属性是Object对象,如何显示该对象的别名 而真正的则保存在其他的地方

 

一般是datasource 绑定一个list对象

list 可以是 自定义类型的对象

 

如:

class Person

{

INT ID;

STRING NAME

}

 

list<Person> listps = new list<Person>();

 

dataSource = listps ;

ListBox.DislayMember = "Name";

ListBox.ValueMember = "ID";

 

Person selPerson = (Person)ListBox.SelectedItem;

int nSelectedID = (int)ListBox.SelectedValue;

 

//do somethings ……

 

 

 

相关文章:

  • 2021-08-05
  • 2021-09-22
  • 2022-12-23
  • 2021-10-07
  • 2022-12-23
  • 2021-08-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
相关资源
相似解决方案