Results 1 to 5 of 5

Thread: Capturing the "Delete Key"

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    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

    Parksie

  2. #2
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    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.
    Show Appreciation. Rate Posts.

  3. #3

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    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.

    Parksie

  4. #4
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    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.

  5. #5

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    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

    Parksie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width