hello everyone i want to know if there is any way or possible to make msflexgrid to be clickable?like if i want to copy a certain data inside the row of the grid and paste it into notepad or excel..im pulling my hair with this one..need your help..thanks

Trapthe keys "Ctrl" and "C" in their event procedure use

Clipboard.Clear
    Clipboard.SetText Screen.ActiveControl.SelText

tnx for your help i will try this one, i have found the same to this code but it does not give the ctrl + c function..i will let you know the result thanks again

i got an error on that Screen.ActiveControl.SelText...seems that it doesn't copy.
i tried this code

Clipboard.Clear
    Clipboard.SetText grd.Clip

this code works perfectly but it does not give the ctrl+c function.instead it automatically copy data being selected in the grid

O.k then the problem is from the event proceedure your "copy" code is. Now copy this code and paste in the form containing the grid. Then cut youe copy code and paste if between the IF BLOCK.

Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbkeyctrl And KeyAscii = vbKeyC Then
    Clipboard.Clear
    Clipboard.SetText grd.Clip
    End If
End Sub

The event proceedure traps any key pressed while the form is active, the IF BLOCK tests whether the "Ctlr + C" is pressed. As such when ever you highlight a text on that form and press "Ctrl + C" it copies...

Corrected Code

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyC Then
        If Shift = 2 Then
             Clipboard.Clear
             Clipboard.SetText grd.Clip
        End If
    End If
End Sub

PS: For this to work set the KeyPreview Property of the your FORM to "True"

Regards
Shaik Akthar

commented: agree, welcome back. +13

thanks for your replies it works great. ^_^

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.