如何基于另一个组合框条目列出组合框数据 [英] How to list combo box data based on another combo box entry

查看:56
本文介绍了如何基于另一个组合框条目列出组合框数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个组合框,第一个组合框包含Subjects,第二个组合框具有类似初学者的级别,然后第三个组合框具有培训师名称。第二个和第三个组合框列表应根据在第一个组合框中选择的条目而有所不同。我有一个信息工作表,其中有2个表,我应该在该表中引用列表,两个表都将主题作为标题,并且每个主题列都按级别(在第一个表上)和培训师(在第二个表上)列出。说主题。并且我已经命名了要引用的表(级别和培训师)。

I have 3 combo boxes, the first one contains Subjects, 2nd combo box has levels like beginner-advanced, then 3rd combo box has Trainer Names. The 2nd and 3rd combo boxes list should vary depending on the entry selected in the first combo box. I have an "Info" worksheet that has 2 tables where i should reference the list, both tables have the Subjects as headers and each subject column list down the levels(on first table) and trainers(on 2nd table) that are available for each said subject. And i have named the tables (Levels and Trainers) for referencing.

推荐答案

请参见下面的代码段。在组合框更改事件上,清除组合框事件,然后在所需的组合框中填充新项目。

See below code snippet. On combobox change event, clear the combo box event and populate the new items in the desired combo box.

Private Sub cmblevels_Change()
    cmbTrainer.Clear
    Select Case LCase$(cmblevels.Text)
        Case "beginner"
            cmbTrainer.AddItem "trainer1"
            cmbTrainer.AddItem "trainer2"
        Case "advanced", "hard"
            cmbTrainer.AddItem "trainer3"
            cmbTrainer.AddItem "trainer4"
            cmbTrainer.AddItem "trainer5"
        Case "easy", "medium"
            cmbTrainer.AddItem "trainer3"
            cmbTrainer.AddItem "trainer6"
            cmbTrainer.AddItem "trainer7"
    End Select
End Sub

Private Sub cmbSubjects_Change()

    cmblevels.Clear
    Select Case LCase$(cmbSubjects.Text)
        Case "english"
            cmblevels.AddItem "beginner"
            cmblevels.AddItem "advanced"
        Case "maths"
            cmblevels.AddItem "easy"
            cmblevels.AddItem "medium"
            cmblevels.AddItem "hard"
    End Select

End Sub

这篇关于如何基于另一个组合框条目列出组合框数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆