将comboBox的结果传递给另一个comboBox [英] Passing the result of a comboBox to another comboBox

查看:85
本文介绍了将comboBox的结果传递给另一个comboBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是新听到的,可以提供一些帮助.我没有设法在任何地方找到此信息,并偶然发现了这个社区,那里似乎有一些非常有帮助的成员!

我有一个应用程序,其中有一个用数据库中的数据填充的comboBox,我需要选择然后用适当的数据填充另一个comboBox,例如:

comboBox 1具有多种食品类型,例如罐装,新鲜,肉类

如果用户选择罐头食品,则comboBox 2将填充数据库中包含的所有罐头食品.

我希望我已经解释得足够好了!我非常感谢您的帮助,因为我为此付出了几天的努力!

预先感谢,

Dan

Hi, Im new hear and could do with a bit of help. I have not managed to find this info anywhere and stumbled accross this community which seems to have some very helpful memebers!

I have an application with a comboBox populated with data from a database, I need the selection to then populate another comboBox with the appropriate data for example:

comboBox 1 has a number of food types i.e. Tinned, Fresh, Meat

if a user selected Tinned, comboBox 2 would be populated with all the tinned food contained within the database.

I hope i''ve explained that well enough! I appreciate any help immensly as I have been struggling with this for a few days now!

Thanks in advance,

Dan

推荐答案

我绝对可以为您提供概念方面的帮助,但我可以为您编写完整的代码.这是您的操作方法

1.在表单加载或您喜欢的任何其他事件(例如单击按钮等)时,将数据加载到第一个组合框中.

2.甚至有一个与组合框调用"onSelectedIndexChange" 相关联的事件.即使在combobox1上,也要编写代码,该代码将根据combobox1中的选择提取数据.您的查询将如下所示

i can definitely help you with concept but except to me write complete code for you. Here is how you can do it

1. Load the data into first combobox on form load or any other event you like(say click of a button etc).

2.There is a even associated with combobox call "onSelectedIndexChange". On this even of combobox1 write the code which will pull the data based on selection made in combobox1. your query will look something like this

select column_name from tablename where index_comuln=''"+combobox1.text+"''"



然后将结果绑定到combobox2.

P.S 请勿复制粘贴此查询.这将不起作用



and then bound the result to combobox2.

P.S Do not copy paste this query. This will not work


这篇关于将comboBox的结果传递给另一个comboBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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