hello! how can i move rows in a grid that has groupbycolumns? I've tried to remove the groupby columns do the Rows.Move() by the row key cell value and then doing the regroup by the default column.
But it didn't work either... Can it be done?
Thank You
Hi,
The Move method simply moves the row to a new position within the same rows collection. It cannot move the row to a new collection. Nor does it change any values in the row.
It sounds to me like you are trying to move a row into a new group. The group is based on the value of a particular cell in the row. So to move a row to a new group, you have to change the Value of the cell for which the row is being grouped. Then you need to call RefreshSortPosition on the row to update the sorting.
what i'm going for here is to change the order of to rows in the grid. it was working fine until i implemented the group element. now the row should still be changing position, but always within the same group.
i tried to remove the grouping, doing the move afterward and then re inserting the sortedcolumn.thanks Mike!
If getOwnersSeleccionadosCount() > 0
Then
For i As Integer = 0 To
dgvTarefasDia.DisplayLayout.Bands(0).SortedColumns.Count - 1
dgvTarefasDia.DisplayLayout.Bands(0).SortedColumns.RemoveAt(i)
Next
For Each dr As UltraGridRow In
dgvTarefasDia.Rows
If dr.Cells("AGEventoId").Value = AGEventoId
dgvTarefasDia.Rows.Move(dr, dr.Index - 1)
dr.RefreshSortPosition()
End
If
dgvTarefasDia.DisplayLayout.Bands(0).SortedColumns.Add(
"OwnerName", False, True
)
Else
If dgvTarefasDia.ActiveRow.Index > 0
dgvTarefasDia.Rows.Move(dgvTarefasDia.ActiveRow, dgvTarefasDia.ActiveRow.Index - 1)
This won't work, because when you add the sorted column, the rows get sorted, and so the Move you performed is overriden by the new sort order.
If you want to move a row that is grouped, then you can only move that row within it's current ParentRows collection.
Thanks Mike!I solved it, by using the ParentCollection as you told.
dgvTarefasDia.ActiveRow.ParentCollection.Move(dgvTarefasDia.ActiveRow, dgvTarefasDia.ActiveRow.Index - 1)