如何在组合框中访问valuemember [英] how to access valuemember in combobox
本文介绍了如何在组合框中访问valuemember的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,我正在使用数据集加载复选框,使用以下代码显示成员为Emp全名,值成员为empID
Hi, in my application i m loading a check box using dataset, display member is Emp full name and value member is empID using the following code
Using datasource As New DataSet()
Using adapter As New SqlDataAdapter(strSQLOwner,sqlConnStr)
adapter.Fill(datasource)
End Using
cboOwner.DataSource = datasource.Tables(0)
cboOwner.DisplayMember = "Name"
cboOwner.ValueMember = "EmpID"
cboOwner.SelectedIndex = -1
End Using
现在,我正在尝试使用valuemember构建查询,但它将值显示为"EmpID",理想情况下应拉取EmpID,请帮助,检查代码.
now i m trying to build a query using the valuemember, but it shows the value as "EmpID" , ideally it should pull the EmpID, please help, check the code.
If (cboOwner.SelectedIndex <> -1) Then
If Trim(Mid(sqlSelIss.ToUpper, sqlSelIss.Length - 3)) = "AND" Then
sqlSelIss &= " created_by = " & cboOwner.ValueMember & " AND "
Else
sqlSelIss &= " AND created_by = " & cboOwner.ValueMember & " AND"
End If
cboOwner.SelectedIndex = -1
End If
在此先感谢
Thanks in advance
推荐答案
,您应该使用SelectedValue属性,如下所示:
you should use SelectedValue property, as below :
sqlSelIss &= " AND created_by = " & cboOwner.SelectedValue & " AND"
并花花公子,为答案打分,并为您的问题选择正确的答案,以便其他人可以使用.
-------------------------
问候
H.Maadani
and, dude, rate answers, and select correct answer to your questions, so others can use that.
-------------------------
Regards
H.Maadani
这篇关于如何在组合框中访问valuemember的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文