Moving rows within a FlexGrid is pretty straight forward. Using Drag and Drop is not required but since that is what you asked about. Make sure you set the DragIcon property of the grid to a valid icon or cursor.
VB Code:
Private Sub MSFlexGrid1_DragDrop(Source As Control, x As Single, y As Single) If Source Is Me.MSFlexGrid1 Then Dim strTemp As String With Me.MSFlexGrid1 'make sure all columns are selected 'required for Clip propertye .Col = 0: .ColSel = .Cols - 1 strTemp = .Clip 'save the data in the selected row .RemoveItem .Row .AddItem strTemp, .MouseRow + 1 'moves row after End With End If End Sub Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) If Button = vbRightButton And Me.MSFlexGrid1.MouseCol = 0 Then Me.MSFlexGrid1.Drag vbBeginDrag Me.MSFlexGrid1.Row = Me.MSFlexGrid1.MouseRow End If End Sub




Reply With Quote