问题描述
我正在Visual C#2005中构建软件(这是我的第一次经验).我使用以下代码填充组合框:
Hi,
I am building a software in visual C# 2005 (it''s my first experience). I use this code to fill a combobox:
DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter("Select CUSTOMER_ID,NAME from CUSTOMERS group by CUSTOMER_ID,NAME", conn);
adapter.Fill(ds);
comboBox1.DataSource = ds.Tables[0].DefaultView;
comboBox1.DisplayMember = "NAME";
comboBox1.BindingContext = this.BindingContext;
一切都好.组合框已填充,仅显示客户名称.那就是我想要的.
但是,当我实现一个搜索按钮时,我想将CUSTOMER_ID作为查询的一部分.因此,单击了客户的组合框,然后单击了搜索按钮,我想生成与所单击的客户名称相对应的所有数据,但要考虑的不是该组合框中显示的名称,而是该名称的customer_ID名称.
你能帮我吗?
谢谢
Everything is fine. The combobox is filled and only the name of the customer is shown. That''s what I wanted.
But when I implement a search button, I want to put as a part of query the CUSTOMER_ID. So the combobox of the customers is clicked and after the search button is clicked I want to produce all the data that correspond to the customer name which was clicked but taking in consideration not the name that was shown in the combobox, but the customer_ID of that name.
May you help me?
Thank you
推荐答案
这篇关于填充组合框,从组合框获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!