Hi..
I have a textbox and two buttons on a form now I want to perform btns event on textbox when I press Enter key from keyboard. so Can I do it.. code like
btnshift_Click(sender, e);
btnsave_Click(sender, e);
any body help.
Perform buttons event on texbox
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Posted May 18, 2011, 1:21 AM EDT
{
if (e.KeyCode == Keys.Enter)
{
//you can call your method here.
btnshift.PerformClick();
btnsave.PerformClick();
}
}
By using button.PerformClick() method,you can inovke the Button.click event Programmatically .
hope this helps you.
Posted May 18, 2011, 1:16 AM EDT
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
//you can call your method here.
}
}
Kanhialal kkRank #8,477 · 221 reputationPosted May 18, 2011, 1:48 AM EDT
your suggested code is working properly but another problem is there which is when I press enter key than the textbox going to empty and that cause string error! because by save button event that textbox should required some values like numbers...
So??
Posted May 18, 2011, 1:58 AM EDT