入力を取得するための単純なフォームがあります。
12 個のボタン、1 個のテキストボックス (無効で読み取り専用)
これは私が入力を処理するために行うことです
Login_KeyDown() は、すべてのUI コンポーネントとフォーム自体のすべてのKeyDownに対して呼び出す一般的なメソッドです。
private void Login_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
Application.Exit();
}
else if (e.KeyCode == Keys.NumPad9 || e.KeyCode == Keys.D9)
{
button3.BackgroundImage = Properties.Resources.button_hover;
button3.ForeColor = Color.White;
pin.Text = pin.Text + "9";
}
else if (e.KeyCode == Keys.Back)
{
button11.BackgroundImage = Properties.Resources.button_hover;
button11.ForeColor = Color.White;
if (pin.Text.Length > 0)
pin.Text = pin.Text.Substring(0, pin.Text.Length - 1);
}
else if (e.KeyCode == Keys.Enter)
{
MessageBox.Show(pin.Text);
}
}
このコードは、アプリを起動すると正常に動作しますが、任意のコンポーネントをクリックすると、残りのコードは正常に動作しますが、「Enter Key Condition」は動作しません。
私の推測では、「Enter Key Condition」は UI コンポーネントなどでは機能していません。
また、 KeyPressEventArgsを使用してKeyChar == 13をチェックする「Key Press Event」を使用しようとしましたが、これも機能しません。
何が問題で、どうすれば解決できますか?
ps どのボタンにもボタン クリック イベントを設定していません。アプリは 100% KBoard ベースです。