使用按钮vb.net更改组合框选定的项目

时间:2013-11-03 19:07:43

标签: vb.net combobox selecteditem

我想知道是否可以使用两个按钮来更改组合框中当前所选项目“向上一个”或“向下一个”。 所以我会有两个按钮:下一个和后一个,当你点击下一个时,组合框中的所选项目将变为列表中较低的一个(1 - > 2),如果你点击后退,它将返回到前一项(1< -2)。 提前谢谢,

1 个答案:

答案 0 :(得分:1)

像...一样的东西。

Private Sub btnUp_Click(sender As System.Object, e As System.EventArgs) Handles btnUp.Click
    If ComboBox1.SelectedIndex > 0 Then
        ComboBox1.SelectedIndex = ComboBox1.SelectedIndex - 1
    End If
End Sub

Private Sub btnDown_Click(sender As System.Object, e As System.EventArgs) Handles btnDown.Click
    If ComboBox1.SelectedIndex < ComboBox1.Items.Count - 1 Then
        ComboBox1.SelectedIndex = ComboBox1.SelectedIndex + 1
    End If
End Sub
相关问题