J imran wrote:
I have a textbox and a button
ok
Your requirement is
J imran wrote:
if i press Enter on the textbox, the button Ok is clicked
if I press ESC ,the button cancel is clicked.
so whats the big deal in that imran it was not that hard to do so
hers your baked code but let me explain u what i have done,
I have generated click event of both the buttons and have wrote code to display messageboxes u may modify the code as per your need
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Button Ok is clicked");
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("Button cancel is clicked");
}
private void textBox1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
button2_Click(sender, e);
}
if (e.KeyCode == Keys.Enter)
{
button1_Click(sender, e);
}
}
Do rate my answer once you find it useful
Thanks & Regards
Radix :rose: