如何从VB.NET中的组合框中获取价值 [英] How to get value from combo box in VB.NET
问题描述
大家好,
我有一个名为客户群的组合框。此组合框将从表CustomerGroup获取数据库中的所有客户组,并在此表中有2列(代码和名称)。我想在组合框中显示名称列,当我保存它时,将代码列添加到其他表(客户表)。
有谁知道如何这样做?
谢谢
TONY
Hi all experts,
i have one combo box called "Customer Group". This combo box will get all customer group in database from table "CustomerGroup" and in this table it has 2 columns (Code and Name). i want to display "Name" columns in Combo box and when i save it get the "Code" Column to other table(Customer Table).
Does anybody know how to do that?
Thanks
TONY
推荐答案
HI,
简单的好友
让我们说,你有一个组合框ComboCustomerGroup
Its simple buddy
Let''s say, you have a combo box "ComboCustomerGroup"
dim CustGroupDT as DataTable=GetCustomerGroupNameAndCode()
Me.ComboCustomerGroup.DataSource=CustGroupDT
Me.ComboCustomerGroup.DisplayMember="Name"
Me.ComboCustomerGroup.ValueMember="Code"
当您将数据保存到表格(客户表)时,请使用
and when you save the data to your table(Customer Table), use
CustomerGroupCode=Me.ComboCustomerGroup.SelectedValue
这将为您提供与组合框所选项目的名称相对应的代码< br $> b $ b
希望它适合你
有一个很好的代码日!!
This will give you the "Code" corresponding to the "Name" of the selected item of your combobox
Hope it works for you
Have a nice code day!!
这篇关于如何从VB.NET中的组合框中获取价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!