Is it possible to change a Winforms combobox to disable typing into it?

C#.NetWinforms

C# Problem Overview


So that it just allows selecting items already inside, but not allow typing/editing the text inside it?

C# Solutions


Solution 1 - C#

Set ComboBox.DropDownStyle to ComboBoxStyle.DropDownList.

Solution 2 - C#

After trying ShaneFulmer's answer, I noticed that the style of the drop down was changed. This was a problem for me and apparently there is no good way of changing it. (Background color doesn't actually change it.)

I ended up adding a keypress handler to prevent adding text.

private void myCombo_KeyPress(object sender, KeyPressEventArgs e)
{
    e.Handled = true;
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJoan VengeView Question on Stackoverflow
Solution 1 - C#Shane FulmerView Answer on Stackoverflow
Solution 2 - C#teynonView Answer on Stackoverflow