1

SOLVED: The issue was DropDownStyle.Simple

Every time I press Enter when typing into folderComboBox it deletes the Text.

It turns out that the problem doesn't occur in a fresh project. It only deletes the text when I use auto completion.

ComboBox folderComboBox = new ComboBox();

void folderComboBox_KeyUp(object sender, KeyEventArgs e)
{

    if (e.KeyCode == Keys.Enter)
    {
        e.SuppressKeyPress = true;
        e.Handled = true;
    }
}
  • I do not have a Form.AcceptButton (mentioned as an issue in another post).

Similar Posts:

  1. Autocomplete on Combobox onkeypress event eats up the Enter key
  2. How do I capture the enter key in a windows forms combobox
Community
  • 1
  • 1
ffhighwind
  • 165
  • 4
  • 13
  • 1
    I use VS 2010 and I tried your code but I can't see your problem. – Hamed May 11 '13 at 13:26
  • I'm running in VS2010 as well. I ran from a fresh project and didn't get the same results. Thanks hamed. Now to see if I can find the issue in the original project... – ffhighwind May 11 '13 at 14:05

1 Answers1

1

Solution:

comboBox.DropDownStyle = DropDownStyle.DropDown; //DEFAULT

Issues:

comboBox.DropDownStyle = DropDownStyle.Simple; //MAIN CAUSE OF ISSUE
comboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
comboBox.AutoCompleteSource = AutoCompleteSource.FileSystemDirectories;
ffhighwind
  • 165
  • 4
  • 13