one more question before i give up

  • Thread starter Thread starter dawn
  • Start date Start date
D

dawn

hi yet again (slowly going crazy here),

when i press enter......the keypress event doesn't get fired....anyone has a
clue as for why this is.....i've been looking in MSDN and they do exactly
what I did....and they claim it works??!!

well anyway if anyone has any idea why they keypress event (nor the keydown
event for that matter) doesn't get fired when i press enter???

thanks
 
When using text boxes and buttons, the parent form may not receive
keypresses.
There may be some override method for this.
 
Ok,

So now I put the KeyPress event on all my buttons....and it still works fine
for every key.....except for the enter keystroke
 
it is set to true......and it works fine for every button
(spacebar.....digits...) but NOT for enter
 
Hi,
KeyPress event is generated only for character keys. *enter* key is not
considered as so.
If you want to catch pressing of *enter* key you have to use KeyDown/Up
events

HTH
B\rgds
100
 
I've tried using KeyDown event as well......but it doesn't trigger either
when i press *enter*
 
Hi Morten,
Morten Wennevik said:
When using text boxes and buttons, the parent form may not receive
keypresses.
There may be some override method for this.

Set form's *KeyPreview* property to *true*.

HTH
B\rgds
100
 
Forgot the code...

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)

{

if(keyData==Keys.Enter)

{

MessageBox.Show("Enter pressed!");

return true;

}

return base.ProcessCmdKey (ref msg, keyData);

}


--
Bob Powell [MVP]
C#, System.Drawing

The October edition of Well Formed is now available.
Find out how to use DirectX in a Windows Forms control
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com
 
Back
Top