View Single Post
 
Old 08-06-2002, 08:51 AM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 19,160
Default Drag and drop between 2 flexgrids

Needed controls for this example:
MSFlexGrid1, MSFlexGrid2 and txtDrag (textbox)

Code:
Private Sub Form_Load() Dim lCol As Long Dim lRow As Long With MSFlexGrid1 .Rows = 10 .Cols = 9 For lRow = 0 To .Rows - 1 For lCol = 0 To .Cols - 1 .TextMatrix(lRow, lCol) = "Src: " & lRow & ";" & lCol Next lCol Next lRow End With With MSFlexGrid2 .Rows = 10 .Cols = 9 For lRow = 0 To .Rows - 1 For lCol = 0 To .Cols - 1 .TextMatrix(lRow, lCol) = "Dst: " & lRow & ";" & lCol Next lCol Next lRow End With End Sub Private Sub MSFlexGrid1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) If Button = vbLeftButton Then With MSFlexGrid1 .Col = .MouseCol .Row = .MouseRow txtDrag.Move .CellLeft, .CellTop, .CellWidth, .CellHeight txtDrag.Text = .Text txtDrag.Drag vbBeginDrag End With End If End Sub Private Sub MSFlexGrid2_DragDrop(Source As Control, x As Single, y As Single) Dim lCol As Long Dim lRow As Long Dim curX As Single Dim curY As Single With MSFlexGrid2 For lRow = 0 To .Rows - 1 .Row = lRow .Col = 0 If y > .CellTop And y < .CellTop + .CellHeight Then For lCol = 0 To .Cols - 1 .Col = lCol If x > .CellLeft And x < .CellLeft + .CellWidth Then .Text = txtDrag.Text Exit For End If Next lCol End If Next lRow End With End Sub
Reply With Quote