我有一个组合框,当该项目被选中并且与其他形式的button.text相同时,button.text会更改用户在文本框中键入的名称。但是,如果该项目是不同的button.text我想隐藏它,所以用户不能选择它或看到它。vb.net combobox hide item
cafetariacombo是ComboBox
Form3.cafetaria2.Text是按钮我改变
If cafetariacombo.SelectedItem = "cafetaria2" Then
Form3.cafetaria2.Text = TextBox1.Text
My.Settings.cafetaria2guardar = Form3.cafetaria2.Text
My.Settings.Save()
end if
我用这个来命名的按钮,我只需要知道,如果我可以隐藏组合框项目。
请帮助我:)
更新一些代码
我在组合框中插入项目列表自己。 我解决了我以前的问题,但现在我需要保存组合框项目的状态,当我离开表单。
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If cafetariacombo.SelectedItem <> Form3.cafetaria1.Text Then
cafetariacombo.Items.Remove("cafetaria1")
End If
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If ComboBox2.SelectedItem = Form3.cafetaria1.Text Then
Form3.cafetaria1.Text = "cafetaria1"
My.Settings.cafetaria1guardar = Form3.cafetaria1.Text
My.Settings.Save()
adicionarproduto.cafetariacombo.Items.Add("cafetaria1")
end if
end sub
当我从ComboBox我在Form1是去除项目,当我再次添加的项目我在窗口2。
当我离开form1时,只需要保存带有已删除项目的组合框。
你“隐藏”的组合框项目通过不包括它的Items集合中。唯一的办法。 – 2014-11-24 01:24:21
您可以使用'cafeteriacombo.Items.Remove(“cafeteria2”)'移除“cafeteria2”项目。 – 2014-11-24 11:51:17