VSFlexGrid Control > VSFlexGrid Properties, Events, and Methods > VSFlexGrid Methods > DragRow Method |
Starts dragging a row to a new position.
[form!]VSFlexGrid.DragRow Row As Long
The DragRow method allows you to initiate row dragging programmatically. The user can then move the row to a new position, and you get notified with the BeforeMoveRow and AfterMoveRow events. The method returns the row's new position.
For example, the code below traps the BeforeMouseDown event to initiate row dragging when the user clicks the right mouse button. The code highlights the row being dragged by setting its background color to red, and restores the background after the dragging process ends.
Private Sub fg_BeforeMouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single, Cancel As Boolean)
With fg
If Button = 2 Then
Cancel = True
Dim r%
r = .Row
.Cell(flexcpBackColor, r, 1, r, .Cols - 1) = vbRed
r = .DragRow(r)
.Cell(flexcpCustomFormat, r, 1, r, .Cols - 1) = False
Debug.Print "Dragged to "; r
End If
End With
End Sub