Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[COLOR=blue]Option Explicit
Dim drgImage As Picture
Dim srcRow As Long
Dim srcCol As Long
Private Sub Form_Load()
[COLOR=green]' Set up a trivial msflexgrid with an image from an imagelist[/color]
MSFlexGrid1.Rows = 4
MSFlexGrid1.Cols = 4
MSFlexGrid1.Row = 3
MSFlexGrid1.Col = 3
Set MSFlexGrid1.CellPicture = ImageList1.ListImages(1).Picture
End Sub
[COLOR=green]'MSFlexgrid DragMode property should be 0 - vbDragManual. Generally this is the default.[/color]
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 [COLOR=green]'start a drag operation.[/color]
End If
End With
End If
End Sub
Private Sub MSFlexGrid1_DragOver(Source As Control, x As Single, y As Single, State As Integer)
[COLOR=green]' Allow default control behaviour to highlight potential target cell[/color]
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 [COLOR=green]' copy source image into target[/color]
.Row = srcRow
.Col = srcCol
Set .CellPicture = Nothing [COLOR=green]' this is a cut and paste, so delete image in source cell[/color]
[COLOR=green]' Rehighlight cell we dropped on as that is generally expected behaviour[/color]
.Row = .MouseRow
.Col = .MouseCol
End With
End If
End Sub
[/color]