Hello:
If I want to move the row down, it only works the first time. If I hit the command a second time, it fails. The issue has to do with
because if I exclude this line, everything behaves as expected, but there is obviously duplicated data.
------
If I want to move the row down, it only works the first time. If I hit the command a second time, it fails. The issue has to do with
Code:
Me.dgvScheduleData.Rows.Remove(myRow)
Code:
Dim dat As Data.DataTable = Me.dgvScheduleData.DataSource
Dim myRow As DataGridViewRow = Me.dgvScheduleData.CurrentRow
Dim currow As Integer = Me.dgvScheduleData.CurrentCell.RowIndex
Dim newrow As DataRow = dat.NewRow
Dim lastrow As Integer = Me.dgvScheduleData.Rows.Count - 2
If currow < lastrow Then
For i As Integer = 0 To Me.dgvScheduleData.ColumnCount - 1
newrow.Item(i) = Me.dgvScheduleData(i, currow).Value
Next
dat.Rows.InsertAt(newrow, currow + 2)
Me.dgvScheduleData.Rows.Remove(myRow)
Me.dgvScheduleData.DataSource = dat
Me.dgvScheduleData.Refresh()
Me.dgvScheduleData.Rows(currow + 2).Selected = True
Me.dgvScheduleData.CurrentCell = dgvScheduleData.Rows(currow + 2).Cells(0)