CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    78

    Copy Datagrid With Ctrl+C

    Hi,

    If you run a query on ACCESS it is displayed in a datagrid. I then type Ctrl+A and Ctrl+C to copy the data from the datagrid into an Excel sheet. I was wondering how to set my VB datagrid to allow me to do the same.

    Thanks,

    RF


  2. #2
    Join Date
    Jul 2001
    Location
    North of France
    Posts
    25

    Re: Copy Datagrid With Ctrl+C

    Hi,

    Try this :


    private Sub CopyGrid1ToClipboard()

    With Grid1
    Clipboard.Clear
    Clipboard.SetText .Clip
    End With
    End Sub

    private Sub Grid1_KeyPress(KeyAscii as Integer)

    'if the user made a selection
    If (Grid1.col <> Grid.ColSel) Or (Grid.row <> Grid.RowSel) then
    'CTRL + C = copy
    If KeyAscii = 3 then
    Call CopyGrid1ToClipboard
    KeyAscii = 0
    Exit Sub
    End If
    End If
    End sub




    Hope it helped.

    Laurent VOISIN.



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

Featured