根据值将Combobox设置为特定项目 [英] Set The Combobox to a specific item according to a value

查看:315
本文介绍了根据值将Combobox设置为特定项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好吧

假设我有一个与数据库中的表绑定的组合框

如果我想让组合框指向其中的特定项目传递给它的值

假设我有一个组合框,其中CustomersName作为显示成员,CustomerID作为值成员

所以如果我想要组合框来指向ID = 10的客户我应该怎么做

这里是我用来填充组合框的代码:

Combobox.DataSource = CustomerBindingSource//我有使用LINQToSQL和一个绑定源来填充它

Combcbox.DisplayMember =CustomerName

Combobox.ValueMember =CustomerID



任何帮助plz?

解决方案

试试这个

 ComboBox1.SelectedValue =  10  


Hi Everybody
Assume i have a combobox that is bounded to table in a database
if i want to make the combobox point to a specific item in it according to a value that is passed to it
assume i have a combobox that have the CustomersName as a display member and the CustomerID as a value member
so if i want the combobox to point to the Customer of ID = 10 how should i do
here is the code i am using to fill the combobox:
Combobox.DataSource = CustomerBindingSource" // I have used LINQToSQL and a binding source to fiil it
Combcbox.DisplayMember = "CustomerName"
Combobox.ValueMember = "CustomerID"

any help plz?

解决方案

try this

ComboBox1.SelectedValue = 10


这篇关于根据值将Combobox设置为特定项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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