Results 1 to 2 of 2

Thread: Delete Key Press on DataGrid

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Delete Key Press on DataGrid

    Is there a way to catch a Delete Key press on a DataGrid. I have tried writing KeyPress and KeyDown events, but it looks like something internal to the component is grabbing the key press first. The symbol on the left changes to the Microsoft changing record pencil.
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    Choose (Overrides) in the top left dropdown box in your code window. In the right dropdown, scroll down to ProcessCmdKey and click it. It will fill in:
    VB Code:
    1. Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
    2.  
    3.     End Function
    but you need to be sure to process the event as normal after you're done with it:
    VB Code:
    1. Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
    2.  
    3.         ' do something with the key press here
    4.  
    5.         Return MyBase.ProcessCmdKey(msg, keyData)
    6.  
    7.     End Function
    If delete is pressed, keyData = Keys.Delete

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