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

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

    To make the text portion of a ComboBox non-editable, set the DropDownStyle property to "DropDownList". The ComboBox is now essentially select-only for the user. You can do this in the Visual Studio designer, or in C# like this:

    stateComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
    

    Link to the documentation for the ComboBox DropDownStyle property on MSDN.

提交回复
热议问题