VB.NET: how to prevent user input in a ComboBox

前端 未结 9 586
[愿得一人]
[愿得一人] 2021-02-03 17:05

How do you prevent user input in a ComboBox so that only one of the items in the defined list can be selected by the user?

9条回答
  •  北恋
    北恋 (楼主)
    2021-02-03 17:36

    Use KeyPressEventArgs,

    Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
        e.Handled = True
    End Sub
    

提交回复
热议问题