I want to execute the code behind my Search Button by pressing Enter. I have the Accept Button property to my search button. However, when i place my button as NOT vi
You could register to the KeyDown-Event of the Textbox, look if the pressed key is Enter and then execute the EventHandler of the button:
private void buttonTest_Click(object sender, EventArgs e)
{
MessageBox.Show("Hello World");
}
private void textBoxTest_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
buttonTest_Click(this, new EventArgs());
}
}