Results 1 to 3 of 3

Thread: Send {Delete} key to datagrid

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Ireland
    Posts
    99

    Send {Delete} key to datagrid

    Hi folks
    Im trying to delete an entry from a datagrid programmatically.
    The entry would be a trapped duplicate record for a table.
    Can I send a delete key call to the the api and thus the datagrid.
    I tried keybd_event and sendkeys.
    no good

  2. #2
    Hyperactive Member
    Join Date
    Feb 2001
    Posts
    421
    This should do it, just make hWnd = the window name.

    In a Form:
    Code:
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    
    Private Const WM_KEYDOWN = &H100
    Private Const WM_KEYUP = &H101
    
    Private Sub Command1_Click()
     SendMessage hWnd, WM_KEYDOWN, 46, 0&
     SendMessage hWnd, WM_KEYUP, 46, 0&
    End Sub
    To find hWnd, you would have to do something like this:

    Code:
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    
    Private Function FindWnd() As Long
     FindWnd& = FindWindow(vbNullString, "Notepad")
    End Function
    [vbcode]
    ' comment
    Rem remark
    [/vbcode]

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Ireland
    Posts
    99
    Cheers Folks
    What would we, the VB novices so without yis all

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