Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to execute a code when enter key is hit. I am using windows application in visual studio 2010/.NET 4. What event handler to be used here?
Posted

yes ...you can..

write a code what you want to execute on key press event..like




C#
private void textBox1_KeyDown(object sender, KeyEventArgs ea)
            {
                if (e.KeyCode == Keys.Enter)
                {
                    MessageBox.Show("Enwter Key Pressed ");
                }
            }


you can call that event where you want..here i'm called in button click..

private void button1_Click(object sender, EventArgs e)
{
textBox1_KeyPress(sender, ea);
}
Thank you..
i hope this may useful for you..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900