Groups | Blog | Home
all groups > visual studio .net general > april 2004 >

visual studio .net general : Key event in VS2003


Thomas Alme
4/20/2004 10:32:15 AM
I used this code and compiled it in VS2002 and there it works fine.

#region Key events
protected override void OnKeyDown(KeyEventArgs kea)
{
switch (kea.KeyData)
{
case Keys.Enter:
....
...
break;
case Keys.Escape:
this.Close();
break;
}
}
#endregion

The class is deriving from System.Windows.Forms.Form

I then compiled it in VS2003 and it woudn't enter the method when I make
a key event like Esc or any other.

Anyone knows why?


Thanks
Thomas


Thomas Alme
4/30/2004 3:41:52 PM
The default value of KeyPreview is sett to false in .NET Framework used by
VS2003. It is true by default in the previous version.

this.KeyPreview = true;


Thats it!


"Thomas Alme" <thomas@freedom-tech.no> skrev i melding
news:OaiO%23HrJEHA.628@TK2MSFTNGP11.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button