Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 在组合框中加载两列_Vb.net - Fatal编程技术网

Vb.net 在组合框中加载两列

Vb.net 在组合框中加载两列,vb.net,Vb.net,我有一个组合框,我想填充SQLServer数据库中的两列。我的代码是: Dim cmd As New SqlCommand("Select hospno,hospno + '--- ' + name as pn from Patient order by hospno", cnn) Dim da As New SqlDataAdapter(cmd) Dim dt As New DataTable() da.Fill(dt) If dt.Rows.Count > 0 Then cbo

我有一个组合框,我想填充SQLServer数据库中的两列。我的代码是:

Dim cmd As New SqlCommand("Select hospno,hospno + '--- ' + name as pn from Patient order by hospno", cnn)
Dim da As New SqlDataAdapter(cmd)
Dim dt As New DataTable()
da.Fill(dt)
If dt.Rows.Count > 0 Then
    cbohospno.ValueMember = "hospno"
    cbohospno.DisplayMember = "pn"
    cbohospno.DataSource = dt
Else
    MessageBox.Show("Empty")
End If

运行时,combox显示的是
name
,而不是
hospno
。如何在组合框中显示
hospno

将DisplayMember设置为“hospno”,您就可以了。
DisplayMember是显示的一个,ValueMember是获得combobox项值时获得的值

WebForms/WPF/Windows Forms/Silverlight?