组合框中的选定值 [英] selected value in a combobox

查看:95
本文介绍了组合框中的选定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我的组合框具有不同的项目,而两个项目具有相同的值.在选择一个值时,它可以显示正确的显示项目.例如,& b具有值2..i我想B,但是它选择A ... plz帮助我...

解决方案

只是尝试使用combobox.selectedindex或combobox.selecteditem .tostring()


这取决于您的要求

如果您需要获取选定的值,那么在多于一个字段中使用相同的值将是一个问题

因此,如果您需要获取选定的文本,请尝试此

combobox.selecteditem.tostring()

这将为您提供选定的项目文本


表示如果选择b,则它将返回b;如果选择b,则它将返回a

试试这个....


在ComboBox中有重复的选择似乎不是一个很好的设计.用户如何区分选择.如果您有一个带有客户"列表的组合,并且您有2个同名客户,那么用户将如何知道哪一个呢?使用组合框选择一个选项,您实际上应该尽量避免重复.如果您真的无法避免重复选择,则应考虑使用其他控件(例如数据网格或列表视图),该控件可以具有多个列以包含区分信息,例如客户地址或ID等.

希望对您有帮助


hi my combobox having different items with two items having same value..at the time of slecting one value it canonte showing correct display item..for example a & b have value 2..i wanna B but it selecting A ...plz help me...

解决方案

just try to use combobox.selectedindex or combobox.selecteditem .tostring()


It depend on your requirement

if you need to get the selected value then it will be problem with same value in more then one filed

so if you need to get the selected text then try this

combobox.selecteditem.tostring()

this will give you a selected item text


means if you select b then it will return b or if it it a then it will return a

try this....


Having duplicate choices in a ComboBox does not seem like a very good design. How would the user differentiate between the choices. If you have a Combo with a list of Customers and you have 2 customers with the same name, how would the user know which is which? Using a ComboBox to select a choice, you should really try to avoid duplicates. If you really cannot get away from having duplicate choices, then you should consider a different control such as a datagrid or listview that can have more than one column to include differentiating information such as a customer address or id or something.

Hope this helps


这篇关于组合框中的选定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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