求助?怎样解决combobox绑定数据源的内容全是一样的情况?

KyKiske22 2016-08-03 05:36:04
代码如下:


实现层:
List<Device> typeidList = new OperateModel().QueryType();
cbx_type.DataSource = typeidList;

模型层:
public class Device
{
public int Id { get; set; }
public string Name { get; set; }
public int ModelId { get; set; }
public int TypeId { get; set; }
}


操作层:
OperateModel类:
public List<Device> QueryType()
{
return new DataQuery().QueryTypeId();
}

QueryType类:
public List<Device> QueryTypeId()
{
String strsql = "select TypeId from Device Where Order By Id";
return new SQLHelperChange().ReaderToList<Device_Record>(new SQLHelper().SelectReader(strsql));
}

最后combobox实现的结果是DeviceModel.Device,我知道是属性被绑定进来,想知道下怎样可以把TypeId属性绑定进来??
...全文
91 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
KyKiske22 2016-08-03
  • 打赏
  • 举报
回复
引用 1 楼 yuankaiwsl 的回复:
这样??
List<Device> typeidList = new OperateModel().QueryType();
cbx_type.DataSource = typeidList
cbx_type.DisplayMember="TypeId"
谢谢兄弟!解决了!!!!!!!!!!!!!!!!!!
巴士上的邂逅 2016-08-03
  • 打赏
  • 举报
回复
这样??
List<Device> typeidList = new OperateModel().QueryType();
cbx_type.DataSource = typeidList
cbx_type.DisplayMember="TypeId"

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧