[英]How to stop Enter key from deleting ComboBox.Text (with AutoComplete)?
SOLVED: The issue was DropDownStyle.Simple 已解决:问题是DropDownStyle.Simple
Every time I press Enter when typing into folderComboBox it deletes the Text. 每次在输入folderComboBox时按Enter键都会删除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;
}
}
Similar Posts: 类似职位:
Solution: 解:
comboBox.DropDownStyle = DropDownStyle.DropDown; //DEFAULT
Issues: 问题:
comboBox.DropDownStyle = DropDownStyle.Simple; //MAIN CAUSE OF ISSUE
comboBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
comboBox.AutoCompleteSource = AutoCompleteSource.FileSystemDirectories;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.