keyDown:首次按下时发生
keyPress:控件具有焦点并且用户按下并释放时发生
keyUp:每次释放时发生
private void Command_CbB_KeyUp(object sender, KeyEventArgs e)
{
ComboBox comboBox = sender as ComboBox;
string command = comboBox.Text.Trim();
Console.WriteLine("Command_CbB_KeyUp,command=" + command);
if (e.KeyCode == Keys.Enter && !string.IsNullOrEmpty(command))
{
//SendCommand_Btn_Click(null, null);
Console.WriteLine("Command_CbB_KeyUp,input");
}
}
private void Command_CbB_KeyPress(object sender, KeyPressEventArgs e)
{
ComboBox comboBox = sender as ComboBox;
string command = comboBox.Text.Trim();
Console.WriteLine("Command_CbB_KeyPress,command=" + command);
Console.WriteLine("e.keyChar=" + e.KeyChar);
if (e.KeyChar == '\r' && !string.IsNullOrEmpty(command))
{
//SendCommand_Btn