请帮助我了解此代码。当用户按下 Enterkey 时,此代码可以运行,但我不知道如何解决这个问题。线问题中的问题。** 我想知道 EnterKey 的 KeyCode
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
Button b = new Button();
b.Text = e.KeyChar.ToString();
if (panel1.Enabled)
{
if (e.KeyChar >= '0' && e.KeyChar <= '9')
{
Numbers(b, null);
foreach (Button c in panel1.Controls)
{
if (c.Text == b.Text)
{
c.Focus();
}
}
}
else
if (e.KeyChar == 13)
btnequal.Focus();
if (e.KeyChar == '+' || e.KeyChar == '-' || e.KeyChar == '/' || e.KeyChar == '*')
{
Operations(b, null);
foreach (Button c in panel1.Controls)
{
if (c.Text == b.Text)
{
c.Focus();
}
}
}
else
if (e.KeyChar == '.')
{
btndot_Click(null, null);
btndot.Focus();
}
else
if (e.KeyChar == '\b')
{
btnbackspace_Click(b, null);
btnbackspace.Focus();
}
else
line problem ===> if (e.KeyChar =='\n')
MessageBox.Show("you press enter");
}