I'm trying this code:
private void txtEmgSearch_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
this.btnEmgSearch.PerformClick();
}
}
The command itself works normally, but there is a IF
if the txtEmgSearch
is empty:
private void btnEmgSearch_Click(object sender, EventArgs e)
{
if (txtEmgSearch.Text == "")
{
MessageBox.Show("Insert part#!");
return;
}
...
When MessageBox
appears and I press ENTER
to give OK
of PopUp the system considers a new ENTER
and re-enters the txtEmgSearch_KeyUp
routine. and so I stay in a Loop, until I click on OK
with the Mouse.
Any way to solve this ??