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

前端 未结 9 618
[愿得一人]
[愿得一人] 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:28

    ---- in form level Declaration of cbx veriable---

    Dim cbx as string
    
    Private Sub comboBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles comboBox1.Enter
        cbx = Me.comboBox1.Text
    End Sub
    
    Private Sub comboBox1_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles comboBox1.Leave
        Me.comboBox1.Text = cbx
    End Sub
    

提交回复
热议问题