我有两个组合框。如果用户从第一个组合框中选择某个值,那么我希望第二个组合框自动更改并选择其相应的值。
例如:
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/