动态组合框在vb.net中选择时重复添加项目

时间:2013-03-18 15:19:40

标签: vb.net

Dim cbox As New ComboBox     // combo box declaration

        If (cmb_item.SelectedIndex = 0) Then  // option select by other combo box
            Label2.Text = "Enter the ID:"
            txt_id.Visible = True
            cbox.Visible = False
        ElseIf (cmb_item.SelectedIndex = 1) Then
            txt_id.Visible = False
            cbox.Visible = True
            Label2.Text = "Select Department:"
            cbox.Width = 202
            cbox.Height = 23
            cbox.Location = New Point(142, 39)
            gbox2.Controls.Add(cbox)
            cbox.Text = "--Select--"
            cbox.Items.Add("Computer Engineering")
            cbox.Items.Add("Electronics & Communication Engineering")
            cbox.Items.Add("Electrical Engineering")
            cbox.Items.Add("Instrumentation & Control Engineering ")
            cbox.Items.Add("Information Technology")
        ElseIf (cmb_item.SelectedIndex = 2) Then
            Me.Dispose()
        End If

如果选择选项0文本框(txt_id)将出现,接下来我将选项更改为1组合框(cbox)将出现并隐藏文本框(txt_id)..同样的方式我更改选项,当cbox获取选择,它使用退出项目更新cbox.item。有什么其他方法可以避免重复的cbox项目吗?

0 个答案:

没有答案