VB里面怎么实现combobox的联动
假如combo1的选项是1,2和3,combo2的选项是abcdef,怎么实现我选择1的时候combo2的选项只有ab可选,同样的选2则只能选择cd,选3则只能选择ef...
假如combo1的选项是1,2和3,combo2的选项是abcdef,怎么实现我选择1的时候combo2的选项只有ab可选,同样的选2则只能选择cd,选3则只能选择ef
展开
2个回答
展开全部
combo1控件的click事件
Private Sub Combo1_Click()
Combo2.Clear
Select Case Combo1.ListIndex
Case 0
Combo2.AddItem "ab"
Case 1
Combo2.AddItem "cd"
Case 2
Combo2.AddItem "ef"
End Select
Combo2.ListIndex = 0
End Sub
窗体load事件
Private Sub Form_Load()
Combo1.Clear
Dim i As Integer
For i = 1 To 3
Combo1.AddItem i
Next
Combo1.ListIndex = 0
Combo2.Clear
Combo2.AddItem "ab"
Combo2.ListIndex = 0
End Sub
Private Sub Combo1_Click()
Combo2.Clear
Select Case Combo1.ListIndex
Case 0
Combo2.AddItem "ab"
Case 1
Combo2.AddItem "cd"
Case 2
Combo2.AddItem "ef"
End Select
Combo2.ListIndex = 0
End Sub
窗体load事件
Private Sub Form_Load()
Combo1.Clear
Dim i As Integer
For i = 1 To 3
Combo1.AddItem i
Next
Combo1.ListIndex = 0
Combo2.Clear
Combo2.AddItem "ab"
Combo2.ListIndex = 0
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询