My original intention in to make enter event for text box to run btnOK_Click event, but after several try I can't make it happen, so I tried another way and try KeyPress for any key but still didn't work, so I made these two simple code, but it still didn't work either;
private void textBox2_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
//enter key is down
//btnOK_Click(this, e);
System.Windows.Forms.MessageBox.Show("My message here");
}
}
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Return)
{
//enter key is down
//btnOK_Click(this, e);
System.Windows.Forms.MessageBox.Show(((char)Keys.Return).ToString());
}
}
Any suggestion? I read some similar questions and they said to set the IsInputKey
property to true but I can't find it anywhere. I use Visual Studio 2008