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 項目の繰り返しを回避する方法はありますか?