代码如下:
实现层:
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属性绑定进来?
实现层:
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属性绑定进来?
解决方案
31
这样?
List<Device> typeidList = new OperateModel().QueryType(); cbx_type.DataSource = typeidList cbx_type.DisplayMember="TypeId"