×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

CUT AND PASTE PICTURE FROM MSFLEXGID

CUT AND PASTE PICTURE FROM MSFLEXGID

CUT AND PASTE PICTURE FROM MSFLEXGID

(OP)
not for me...

possible to cut picture from a msflexgrid cell and paste in other cell, with left click button of mouse?

RE: CUT AND PASTE PICTURE FROM MSFLEXGID

Sure

RE: CUT AND PASTE PICTURE FROM MSFLEXGID

How to?

RE: CUT AND PASTE PICTURE FROM MSFLEXGID

sal21 / 2009luca - what have you tried so far? Show here your effort to solve your issue.

PS. And why do you use 2 login names?

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson

RE: CUT AND PASTE PICTURE FROM MSFLEXGID

(OP)
Sorry me Andy,
no idea to create code for drag and drop, never used

RE: CUT AND PASTE PICTURE FROM MSFLEXGID

Did you try to Google anything?

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson

RE: CUT AND PASTE PICTURE FROM MSFLEXGID

Here's an example. I am not including much in the way of explanation, as it seems you never really pay much attention to that. As ever it is an EXAMPLE of how to do this, not a bespoke piece of code for your particular situation. Nor does it cover niceties such as aborting, or dropping in or signalling areas of the control you don't want to drop in

CODE -->

Option Explicit
Dim drgImage As Picture
Dim srcRow As Long
Dim srcCol As Long

Private Sub Form_Load()
    ' Set up a trivial msflexgrid with an image from an imagelist
    MSFlexGrid1.Rows = 4
    MSFlexGrid1.Cols = 4
    MSFlexGrid1.Row = 3
    MSFlexGrid1.Col = 3
    Set MSFlexGrid1.CellPicture = ImageList1.ListImages(1).Picture
End Sub

'MSFlexgrid DragMode property should be 0 - vbDragManual. Generally this is the default.
Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = vbLeftButton Then
        With Me.MSFlexGrid1
            If .CellPicture <> 0 Then
                .DragIcon = .CellPicture
                ' capture source cell info
                Set drgImage = .CellPicture
                srcRow = .Row
                srcCol = .Col
                .Drag vbBeginDrag 'start a drag operation.
            End If
        End With
    End If
End Sub

Private Sub MSFlexGrid1_DragOver(Source As Control, x As Single, y As Single, State As Integer)
    ' Allow default control behaviour to highlight potential target cell
    If Source Is Me.MSFlexGrid1 Then
        MSFlexGrid1.Col = MSFlexGrid1.MouseCol
        MSFlexGrid1.Row = MSFlexGrid1.MouseRow
    End If
End Sub

Private Sub MSFlexGrid1_DragDrop(Source As Control, x As Single, y As Single)
    If Source Is Me.MSFlexGrid1 Then
        With Me.MSFlexGrid1
            Set .CellPicture = drgImage ' copy source image into target
            
            .Row = srcRow
            .Col = srcCol
             Set .CellPicture = Nothing ' this is a cut and paste, so delete image in source cell
             ' Rehighlight cell we dropped on as that is generally expected behaviour
             .Row = .MouseRow
             .Col = .MouseCol
        End With
    End If
End Sub
 

RE: CUT AND PASTE PICTURE FROM MSFLEXGID

(OP)
Tks strongm,
but i cannot test now.

RE: CUT AND PASTE PICTURE FROM MSFLEXGID

Guess that's also the case for, e.g.:

thread222-1814206: OPEN TXT AND SAVE TO UTF8
thread222-1814146: select range of cell and clear all
thread222-1813837: possible to intercept the row and column on msflexgrid without to use the mousemove event
thread222-1813768: find in a collection

all fairly recent threads started by you that have been left hanging. Appreciate that you may be busy, but so are the people who provide help here, and the repeated behaviour of asking questions, and then leaving them open (in the sense that we have no idea if you have seen the help, whether the help was of any use, or no response to questions seeking additional info from you) gives the appearance that you think your time is more valuable than our time.

And once people begin to get that impression, the less likely they will be to carve out some of their own valuable time to help you out. Just saying.

RE: CUT AND PASTE PICTURE FROM MSFLEXGID

(OP)
tested.
only one...

have error in : .DragIcon = .CellPicture

but i have commented the line in error and work!
Tks

RE: CUT AND PASTE PICTURE FROM MSFLEXGID

Odd. Due to a quirk, that shouldn't have generated an error, but properly it should be

Set .DragIcon = .CellPicture

RE: CUT AND PASTE PICTURE FROM MSFLEXGID

Yep, that'll be because the image you are using in the flexgrid isn't actually an icon.

You can fix this by changing

Set MSFlexGrid1.CellPicture = ImageList1.ListImages(1).Picture

to

Set MSFlexGrid1.CellPicture = ImageList1.ListImages(1).ExtractIcon

RE: CUT AND PASTE PICTURE FROM MSFLEXGID

(OP)
nice!
Tks

RE: CUT AND PASTE PICTURE FROM MSFLEXGID

And again, as in many other posts mentioned here by strongm, no recognition of helpful post by sal21 / 2009luca with the use of a purple star.

mintjulep may be right... sad

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close