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

后端 未结 5 1048
旧时难觅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:50

    To add a Visual Studio GUI reference, you can find the DropDownStyle options under the Properties of the selected ComboBox:

    enter image description here

    Which will automatically add the line mentioned in the first answer to the Form.Designer.cs InitializeComponent(), like so:

    this.comboBoxBatch.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    

提交回复
热议问题