special enter function !!

  • Thread starter Thread starter Tor Lund
  • Start date Start date
T

Tor Lund

how do i create a function that does "something" every time i press enter. i
have used the form.AcceptButton property but it does not override if a
button has the focus. then enter will ´click the button and not load my
enter "code".

can anybody help `??

tor lund
 
how do i create a function that does "something" every time i press enter. i
have used the form.AcceptButton property but it does not override if a
button has the focus. then enter will ´click the button and not load my
enter "code".

can anybody help `??

tor lund


Hi,

Set the form KeyPreview property to true and add this handler:

private void frmMain_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs
{
if (e.KeyChar == 13)
MessageBox.Show ("Enter pressed!"); // here you call your enter "code"
}

Regards,
Peter
 
Back
Top