如何从组合框中选择一个项目并在另一个组合框中获取我想要的详细信息? [英] how can i select a item from combobox and get me the details that i want in another combobox?

查看:78
本文介绍了如何从组合框中选择一个项目并在另一个组合框中获取我想要的详细信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好世界!

i有疑问...

我的项目视觉基础



i有一个comboBox,来自databaseOracle的信息,

,当我的combobox.text收到信息时,我必须选择给我的一个选项。



从我选择了来自combobox.text的项目之后,我的另一个组合将是:combobox.enabled = true,我将解决组合框的项目



问题:如何从combox中选择一个项目并在另一个组合框中获取我想要的详细信息?



更好地理解我的程序 a支架车 <小>





如果您帮助我,我将不胜感激。



最好的问候,

Nillo123。

Hello world!
i have a doubt...
my project "visual basic"

i have a comboBox, with information from databaseOracle,
that when my combobox.text receive the information i must select one of the options that was gives to me.

after i select the item from combobox.text, my other combo will be : combobox.enabled = true, and i will pike the item of combobox

problem: how can i select a item from combox and get me the details that i want in another combobox?

to understand better my program its like a stand car


If you help me,I will appreciate.

With best regards,
Nillo123.

推荐答案

在表单设计中双击组合框它将为您打开组合框选择的索引更改事件。

在该事件中编写用于从d检索数据的代码atabase。

获取组合框所选项目的价值:

Double click on combobox in form design it will open combobox selected index change event for you.
In that event write code for retrieving data from database.
To get value of selected item of combobox:
dim str as string =combobox1.selecteditem 



并将其与where子句中的select查询一起使用,将该数据存储在dataadapter中并填充数据集



在下面的示例中我使用的是sql server数据库:

示例:




and use it with select query in where clause, store that data in dataadapter and fill dataset

In below example I am using sql server database:
Example:

Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
       Dim str As String = ComboBox1.SelectedText

       Dim cn As New SqlConnection("Connection String")
       Dim cmd As New SqlCommand("Select subitem from ItemMaster where subitem='" + str + "'", cn)
       cn.Open()

       Dim da As New SqlDataAdapter(cmd)
       Dim ds As New DataSet
       da.Fill(ds)
       ComboBox2.DataSource = ds.Tables(0)

   End Sub


这篇关于如何从组合框中选择一个项目并在另一个组合框中获取我想要的详细信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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