Private Sub BtnUp_Click(sender As System.Object, e As System.EventArgs) Handles BtnUp.Click
Dim CurrentRow As DataGridViewRow = DataGridView1.CurrentRow
Dim Results As DataGridViewRow = CType(CurrentRow.Clone(), DataGridViewRow)
Dim currentIndex As Int32 = DataGridView1.CurrentRow.Index
DataGridView1.Rows.RemoveAt(currentIndex)
Dim NewIndex As Int32 = CInt(IIf(currentIndex = 0, 0, currentIndex - 1))
For Row As Int32 = 0 To CurrentRow.Cells.Count - 1
Results.Cells(Row).Value = CurrentRow.Cells(Row).Value
Next
DataGridView1.Rows.Insert(NewIndex, Results)
DataGridView1.CurrentCell = DataGridView1(0, NewIndex)
End Sub
Private Sub BtnDown_Click(sender As System.Object, e As System.EventArgs) Handles BtnDown.Click
Dim CurrentRow As DataGridViewRow = DataGridView1.CurrentRow
Dim Results As DataGridViewRow = CType(CurrentRow.Clone(), DataGridViewRow)
Dim currentIndex As Int32 = DataGridView1.CurrentRow.Index
DataGridView1.Rows.RemoveAt(currentIndex)
Dim NewIndex As Int32 = CInt(IIf(currentIndex = DataGridView1.Rows.Count,
DataGridView1.Rows.Count, currentIndex + 1))
For Row As Int32 = 0 To CurrentRow.Cells.Count - 1
Results.Cells(Row).Value = CurrentRow.Cells(Row).Value
Next
DataGridView1.Rows.Insert(NewIndex, Results)
DataGridView1.CurrentCell = DataGridView1(0, NewIndex)
End Sub