|
-
Jan 12th, 2009, 05:59 AM
#1
Thread Starter
Fanatic Member
Capturing the "Delete Key"
OK folks.
I have a control and wish ti capture the "Delete Key".
I first tried this :
Code:
private void desktopThumbs_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 127)
{
MessageBox.Show("DELETE HIT");
}
}
And nothing. Literaly nothing happens no matter what keys I hit.
I then tried this :
Code:
private void desktopThumbs_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
MessageBox.Show("DELETE HIT");
}
}
And this event does fire when I hit most keys but not the "Delete" key.
How do I capture the delete key ?
Thanks In Advance
-
Jan 12th, 2009, 06:33 AM
#2
Re: Capturing the "Delete Key"
KeyPress is meant to capture only alphanumeric characters. For special characters, you need either KeyDown or KeyUp event.
So your second try should work. Adding to this, I'd suggest you to set the KeyPreview Property of the Form/Control (if it exposes) to True. Just give it a try.
-
Jan 12th, 2009, 08:33 AM
#3
Thread Starter
Fanatic Member
Re: Capturing the "Delete Key"
No joy I'm afraid.
There is no keypreview property and that damn "Del" key never ever seems to fire off the KeyDown event.
This is driving me nuts.
-
Jan 12th, 2009, 12:25 PM
#4
Re: Capturing the "Delete Key"
What kind of control is it?
I just tried with a checkbox and a textbox and both of those showed the messagebox.
-
Jan 13th, 2009, 04:28 AM
#5
Thread Starter
Fanatic Member
Re: Capturing the "Delete Key"
Its a thumbnail third party control which displays thumbnails of tiff files.
Still don't get it. Why is the Del key causing me grief. grrrr
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|