在组合框项目的帮助下显示/隐藏另一个组合框 [英] show/hide another combobox, with the help of combobox items
问题描述
我有一个小问题,我正在创建一个简单的搜索应用程序,它有一个文本框、一些组合框、单选按钮和一个搜索按钮.单选按钮名称视频"、音频"、图片"等.when radiobutton of video is selected, a combobox is appear having options "YouTube", "Metacafe" etc我希望当我单击视频组合框中的Metecafe"项目时,会出现另一个组合框,其中包含娱乐"、操作方法"、+18"等(视频搜索类别)等项目.所以如何在组合框项目的帮助下显示/隐藏其他 COBOBOX"希望你明白我的问题.屏幕截图我不知道这是否可能,因为我是 VB 初学者我的英语不是很好,所以请看下面的代码:)
I have a little problem that i'm creating a simple search application which have a TEXT box and some combo boxes and radio buttons and a search button. radio button names "Videos", "Audios", "Pics" etc.. when radiobutton of video is selected, a combobox is appear having options "YouTube", "Metacafe" etc I want that when i click "Metecafe" item in combobox of video, an other combo box appear having items Like "Entertainment", "How To", "+18" etc(categories of video search). so "HOW TO SHOW/HIDE AN OTHER COBOBOX WITH THE HELP OF A COMBOBOX ITEM" hope you have understood my problem. screen shoot i don't know it is possible or not becux i'm beginner in VB my English is not so good so please see below code:)
if combobox1.SelectedItem = "PAKISTAN" Then
combobox2.Visible = True
End if
if combobox1.SelectedItem = "INDIA" Then
combobox3.visible = true
combobox2.visible = false
End if
显然这段代码是错误的,这是我想要做的一个例子提前谢谢大家..
Obviously this code is wrong, this is a example that what i want to do Thanks to all in advance..
注意:我试过这个代码,但它不起作用..
NOTE: i have try this codes but its not working..
if ComboBox1.Items(ComboBox1.SelectedIndex).ToString() = "PAKISTAN" Then
ComboBox2.Visible = True
End if
抱歉拼写和语法错误:(
sorry for spell and grammatical mistakes:(
推荐答案
尝试使用 SelectedItem 这样的属性
Try using the SelectedItem Property like this
Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.SelectedItem.ToString = "PAKISTAN" Then
ComboBox2.Visible = True
End If
End Sub
由于您要检查多个国家/地区,您可以使用 选择案例 这样的声明
Since you are wanting to check for multiple country's you can use a Select Case Statement like this
Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Select Case ComboBox1.SelectedItem.ToString
Case "PAKISTAN"
ComboBox2.Visible = True
ComboBox3.Visible = False
Case "INDIA"
ComboBox3.Visible = True
ComboBox2.Visible = False
Case Else
ComboBox2.Visible = False
ComboBox3.Visible = False
End Select
End Sub
这篇关于在组合框项目的帮助下显示/隐藏另一个组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!