Combox显示成员未显示使用列表对象c#

时间:2015-06-25 06:57:18

标签: combobox objectdatasource

这是obj def:

def set_foo(self, a):
    print a

列表是

class TestScanOrder { public long OrderCodeField { get; set; } public long PatientCodeField { get; set; } public string PatientNameField { get; set; } public string PatientVal { get; set; } public DateTime DateTimeField { get; set; } public TestScanOrder(DateTime dt,long order,long pateintCode,string patientName,string patientVal) { DateTimeField = dt; OrderCodeField = order; PatientCodeField = pateintCode; PatientNameField = patientName; PatientVal = patientVal; }

TestScanOrder[] list = new TestScanOrder[]{ new TestScanOrder( Convert.ToDateTime("06/24/2015"), 1910, 65547, "Raja", 65547 + "~" + 1910 + "~" + 1 ), new TestScanOrder(Convert.ToDateTime("06/25/2015"), 1911, 65548, "Roja", 65548 + "~" + 1911 + "~" + 1 ), new TestScanOrder( Convert.ToDateTime("06/26/2015"), 1912, 65549, "Peter", 65549 + "~" + 1912 + "~" + 2 ), new TestScanOrder( Convert.ToDateTime("06/27/2015"), 1913, 65550, "jaya", 65550 + "~" + 1913 + "~" + 2 ), new TestScanOrder(Convert.ToDateTime("06/28/2015"), 1914, 65551, "Vijaya", 65551 + "~" + 1914 + "~" + 1 ) };

然而,当我开火时,这就是我所得到的:

enter image description here

如何在组合框中获取PatientName 请帮我解决这些问题

1 个答案:

答案 0 :(得分:0)

在“TestScanOrder”类中,患者姓名的属性为“PatientNameField”,因此请使用以下命令指定组合框的显示成员 -

cbPatients.DisplayMember = "PatientNameField";

如果为显示成员指定了无效的属性名称,则代码不会中断,而是使用数据源中类的完全限定名称填充组合。