I'm writing a GUI in C#, Visual Studio 2008, using the Designer and WinForms. I've got a ComboBox control, and I'd like it to only allow to select from the provided options and not to accept a user-entered string. It doesn't appear to have a ReadOnly property, and disabling it hinders the readability of the control (as well as disallowing user-selection).
+3
A:
Set the ComboBox.DropDownStyle property to ComboBoxStyle.DropDownList.
OregonGhost
2008-10-02 15:20:46
A:
Use code similar to the following to set the allowed options and only those options.
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
comboBox1.Items.AddRange(new object[] {
"One",
"Two",
"Three",
"Four"});
David Max
2008-10-02 15:27:35