学习VB.Net-在组合框中单击一个项目,并想检索该项目的相应数据 [英] Learning VB.Net - Clicked an item in a combo box and want to retrieve the corresponding data for that item

查看:67
本文介绍了学习VB.Net-在组合框中单击一个项目,并想检索该项目的相应数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.

我自己学习VB.Net.我使用ODBC连接到数据库,并且能够检索数据以填充组合框.当我在组合框中单击一个项目时,我想为我选择的记录检索相应的数据,并在表单上填写所需的数据字段.我知道如何填写其余字段.我不知道如何通过单击组合框来检索剩余数据.

任何人都可以向我解释或提供实现此结果的代码吗?

Hi.

Learning VB.Net on my own. I''m connected to a database using ODBC and I''m able to retrieve data to fill in a combo box. When I click on an item in the combo box, I want to retrieve the corresponding data for the record I selected and fill in the required data fields on the form. I know how to fill in the remaining fields. I don''t know how to get from clicking the combo box to retrieving the remaining data.

Can any one explain to me or provide me with the code to achieve this result?

Thanks.

推荐答案

处理SelectedIndexChanged事件,并使用SelectedItem属性:
Handle the SelectedIndexChanged event, and use the SelectedItem property:
Private Sub myComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles myComboBox.SelectedIndexChanged
    Dim cb As ComboBox = TryCast(sender, ComboBox)
    If cb IsNot Nothing Then
        Dim item As String = DirectCast(cb.SelectedItem, String)
        ...
    End If
End Sub


我强烈建议您找到一门课程或一本书-他们以结构化的方式介绍材料,这应确保您在继续学习时不会错过重要的细节.如果您尝试通过随便做"来学习,我保证您会在旅途中丢失很多东西,并且使自己变得比您需要做的事情难得多!


I would strongly suggest you find a course, or a book - they present the material in a structured way, which should ensure that you do not miss important details as you go along. If you try to learn by "just doing it" I guarantee you will be missing lots as you go, and making things a lot harder for yourself than you need to!


这篇关于学习VB.Net-在组合框中单击一个项目,并想检索该项目的相应数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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