I have made this sub procedure. Try by using it on Button click event in your code. Hope this will work as per your requirement.
Code:
Public Sub MoveUp(ByRef firstRow As System.Windows.Forms.DataGridViewRow, ByRef nextRow As System.Windows.Forms.DataGridViewRow)
'Create a temporary value
Dim temp As Object
Dim temp2 As Object
'Loop through each cell in the firstRow datagridview
Dim i As Integer
For i = 0 To firstRow.Cells.Count - 1
'If the cell isn't read only, then swap them.
If firstRow.Cells(i).ReadOnly = False Then
'use the temp object to swap the cell values.
temp = firstRow.Cells(i).Value
temp2 = nextRow.Cells(i).Value
firstRow.Cells(i).Value = temp2
nextRow.Cells(i).Value = temp
End If
Next
End Sub
Bookmarks