How can I make a ComboBox non-editable in .NET?

后端 未结 5 1038
旧时难觅i
旧时难觅i 2020-11-28 23:43

I want to have a \"select-only\" ComboBox that provides a list of items for the user to select from. Typing should be disabled in the text portion of the

5条回答
  •  再見小時候
    2020-11-29 00:41

    To continue displaying data in the input after selecting, do so:

    VB.NET
    Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
        e.Handled = True
    End Sub
    
    
    
    C#
    Private void ComboBox1_KeyPress(object sender, KeyPressEventArgs e)
    {
        e.Handled = true;
    }
    

提交回复
热议问题