我找不到原因,为什么在我的情况下 DisplayMember 被正确填充,而 ValueMember 只得到一个字符串(列名)。对于不同的组合框、列名和表,它是相同的。
Using comm3 As SqlCommand = New SqlCommand("SELECT PID, RTRIM(Desc) as Desc FROM Conds WHERE Typ = 3", oConn)
Dim rs As SqlDataReader = comm3.ExecuteReader
Dim dt As DataTable = New DataTable
dt.Load(rs)
cbConditionPayment.ValueMember = "PID"
cbConditionPayment.DisplayMember = "Desc"
cbConditionPayment.DataSource = dt
End Using 'comm3
因此,DisplayMember 获取的值类似于“Condition1、Condition2、Condition3,....”,而 ValueMember 获取的值是“PID, PID, PID, PID,....”而不是“1, 2, 3, 18, 22, .... ..”
一定是什么蠢事……
问候,
橡木