程式碼如下:
Dim Move_Command As Integer '拖曳MSFlexGridS控件
Dim xx As Long, yy As Long '拖曳MSFlexGridS控件
Private Sub Command1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
Command1(Index).ZOrder
Move_Command = Index
Command1(Index).Drag vbBeginDrag
xx = x: yy = y
End Sub
Private Sub Form_DragDrop(Source As Control, x As Single, y As Single)
Command1(Move_Command).Move x - xx, y - yy
End Sub