在另一个组合框选定值的基础上设置组合框值-VB.NET [英] Set Combobox Value base on another Combobox Selected Value - VB.NET
本文介绍了在另一个组合框选定值的基础上设置组合框值-VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个组合框。如果用户从第一个组合框中选择某个值,那么我希望第二个组合框自动更改并选择为其对应的值。
I have two comboboxes. If the user selects a certain value from the first combobox then I want the second combobox to automatically change and select to its corresponding value.
例如:
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文