我在组合框中有一个组合框。组合框有2个项目。即“鞋子”和“衬衫”。我正在尝试做的是..在运行时,当我选择Shirts时,该事件将添加一个组合框。但是当我选择鞋子时,它会添加一个文本框。
当我选择一次时,我设法让它工作。 (例如,我首先选择了衬衫。它添加了一个组合框)但是在再次挑选之后,添加的组合框不会被移除并且文本框不可见(例如,在挑选衬衫之后。我选择了鞋子。组合框仍然存在和文本框无处可寻。)
我正在使用此代码。
Dim SML As New ComboBox
If ComboBox2.Text = "Shirts" Then
SML.Size = New Size(35, 20)
SML.Location = New Point(103, 158) 'set the position according to your layout
SML.Items.Add("S")
SML.Items.Add("M")
SML.Items.Add("L")
SML.Visible = True
SML.Name = "A"
GroupBox1.Controls.Add(SML) 'add it to form's control collection.
GroupBox1.Refresh() 'If in panel etc. change Me with that control.
ElseIf ComboBox2.Text = "Shoes" Then
GroupBox1.Controls.Remove(SML)
GroupBox1.Refresh()
TextBox5.Enabled = True
Else
TextBox5.Enabled = False
End If