如何从ValueMember获取ComboBox值? [英] How to get ComboBox Value from ValueMember?

查看:86
本文介绍了如何从ValueMember获取ComboBox值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

帮助:我在C中比较贵#

我的桌子是

Emp Id EmpName

1001名称1

1002 Name2

1003 Name3

..我正在使用ComboBox将这三个名称显示为ComboBox1.DisplayMember =EmpName和ComboBox1.ValueMember =EmpId。现在我的问题是......当我在ComboBox1中选择Name2时,我希望获得值1002。 Plz帮帮我...

Help : I'm Bigineer in C#
my table is
Emp Id EmpName
1001 Name1
1002 Name2
1003 Name3
..I'm using ComboBox to display these three names as ComboBox1.DisplayMember="EmpName" and ComboBox1.ValueMember="EmpId". Now my question is....When I choose "Name2" in ComboBox1, I want to get the value "1002". Plz help me...

推荐答案

你可以使用这样的组合框的SelectedValue属性:



You can use SelectedValue Property of Combo box like this:

int selectedValue = Convert.ToInt32(comboBox1.SelectedValue);





我希望有帮助。



I hope thi helps.


为什么不读一些文档首先 [ ^ ],例如如果您需要了解Windows格式组合框控件的属性和方法,请 Google查找msdn文档 [ ^ ]

现在您可以快速搜索 ValueMember 属性,您可以找到其他相关属性,可用于获取所选值。
Why not reading some documentation first[^], for example if you need to know about properties and methods of windows form combobox control, Google and find the msdn documentation[^]
Now you can do a quick search for ValueMember property and you can find other related properties which can use to get the selected value.

这篇关于如何从ValueMember获取ComboBox值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆