vb.net - 根据另一个组合框选定值设置组合框值 - VB.NET

标签 vb.net combobox

我有两个组合框。如果用户从第一个组合框中选择某个值,那么我希望第二个组合框自动更改并选择其相应的值。

例如:

If Me.InstitutionAdvisoryFirmsComboBox1.SelectedValue = 3 Then 
     Me.WeightComboBox1.SelectedValue = 2

我也尝试过:

If Me.InstitutionAdvisoryFirmsComboBox1.SelectedText = "Internal Guidelines" Then                 
    Me.WeightComboBox1.SelectedText = "None"

有人可以帮忙吗?

最佳答案

//selected index changed event for the combo box 

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles InstitutionAdvisoryFirmsComboBox1.SelectedIndexChanged

    If Me.InstitutionAdvisoryFirmsComboBox1.SelectedIndex = 3 Then 
        If Me.WeightComboBox1.Items.Count >= 2 Then // make sure you are not accessing an index out of range
            Me.WeightComboBox1.SelectedIndex = 2
        End If
    End If

End Sub 

关于vb.net - 根据另一个组合框选定值设置组合框值 - VB.NET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25184896/

相关文章:

javascript - 根据 comboBox 值启用/禁用 txtBox

mysql - 如何使用 VB.NET treeview 从 MySQL 作为数据库创建 TreeView

css - Vb.net 8.5 x 11paper 到 webform

asp.net - 根据另一个表中的数据从表中选择行

vb.net - 如果选中复选框,则运行 "something"

c# - 如何验证是否至少选择了 5 个组合框中的 2 个 c#

c# - 调试时隐藏 DLL 中的代码

javascript - 使用 javascript trim 多余的空间

java - 根据组合框选择 JavaFX 和 Java 1.7 的组合更改 TextField 值

javascript - 如何将组合框选定的值和单选按钮列表选中的值从 View 传递到 Controller