组合框到文本框ID号视图 [英] Combo box to Textbox Id number view

查看:88
本文介绍了组合框到文本框ID号视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要你的帮助guuuys。我是vb.net的新手。虽然编程不是我的专业。我可以问一下如何使用组合框更改ID?

例如。

我在组合框中有金属,家具等。现在,我想下拉组合框然后我点击金属,文本框必须显示。 Metal-0000#,但我不知道如何编码。请帮忙。感谢。

I need your help guuuys. Im new to vb.net. Programming is not my Major though. Can I ask how can I change ID using combo box?
For example.
I have Metal, Furniture, etc inside a combo box. Now, i want to drop down combo box then I click Metal, textbox must Show. Metal-0000#, but I dont know how to code it. Please help. Thankss.

推荐答案

ChiPats,对于你我强烈建议你在这个网站上花很少的钱, http://www.learnvisualstudio.net/ [ ^ ]



这些是迄今为止,一些信息量最大的视频,同时也非常容易理解。



我用了一会儿,花了很多钱。它将让您睁大眼睛,了解在visualBasic.net开发中等待您的全部可能性。我现在因为这个而沉迷于编程。



我特别陷入数据库问题,甚至不了解它们是如何工作的。现在我正在为我工​​作的公司开发数据库和界面。我不是因为这个人。
ChiPats, for you I will highly recommend spending a VERY SMALL amount of money at this site, http://www.learnvisualstudio.net/[^]

These are by far, some of the most informative videos that are, at the same time, very easy to understand.

I used them for a short while, it was money well spent. It will open your eyes to the full world of possibilities that wait for you in visualBasic.net development. I am now addicted to programming because of this.

I was especially caught up in database issues and not even understanding how they work. Now I'm in the process of developing a database and interface for the company where I work. I't because of this guy.


试试这个开始:



Try this to get started:

Public Class Form1
    Dim itemList As List(Of Item)


    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
        MyBase.OnLoad(e)
        Dim i As Integer
        Dim n As Integer
        Dim s As String
        Dim obj As Item

        Me.itemList = New List(Of Item)
        Me.itemList = Item.ListAll()
        n = Me.itemList.Count

        For i = 0 To n - 1
            obj = Me.itemList.Item(i)
            s = obj.name
            Me.ComboBox1.Items.Add(s)
        Next
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Dim i As Integer
        Dim n As Integer
        Dim txt As String
        Dim obj As Item

        n = Me.itemList.Count
        i = Me.ComboBox1.SelectedIndex
        If i >= 0 & i < n Then
            obj = Me.itemList(i)
            txt = obj.name & obj.id.ToString() & "#"

            Me.TextBox1.Text = txt
        End If

    End Sub
End Class

Public Class Item
    Public name As String
    Public id As Integer

    Public Sub New(ByVal i As Integer, ByVal itemName As String)
        name = itemName
        id = i
    End Sub

    Public Shared Function ListAll() As List(Of Item)
        Dim newItem As Item

        Dim data(0 To 2) As String
        data(0) = "Metal"
        data(1) = "Furniture"
        Dim items As List(Of Item)
        items = New List(Of Item)

        For i As Integer = 0 To 1
            newItem = New Item(i, data(i))
            items.Add(newItem)

        Next

        Return items

    End Function

End Class


这篇关于组合框到文本框ID号视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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