Skip to main content
A newer version of this page is available. .

VGridControlBase.MoveRow(BaseRow, BaseRow, Boolean) Method

Moves the specified row to the position specified.

Namespace: DevExpress.XtraVerticalGrid

Assembly: DevExpress.XtraVerticalGrid.v19.1.dll

Declaration

public void MoveRow(
    BaseRow source,
    BaseRow destinationRow,
    bool insertBefore
)

Parameters

Name Type Description
source BaseRow

A BaseRow descendant that represents the row moved.

destinationRow BaseRow

A BaseRow descendant that represents the row before which the source row should be moved or the parent row whose child row collection it should be appended to.

insertBefore Boolean

true if the source row should be moved before the destination row; false if the source row should be appended to the child rows collection of the destination row.

Remarks

The MoveRow method moves the row to the specified position within the vertical grid. Note that child rows (if any) are moved too.

Calling the MoveRow method has no effect in the instances listed below:

  • the source parameter is the null reference;
  • the row specified either by the source or dest parameter belongs to another vertical grid control;
  • the source and dest parameters represent the same row;
  • the row specified by the source parameter is a parent to the row which is specified by the dest parameter;
  • if the insertBefore parameter is set to true and the row which is specified by the dest parameter contains the source row in its child rows collection.

If the dest parameter is a null reference, the source row is appended to the grid’s VGridControlBase.Rows collection.

Note

The MoveRow method moves the row regardless of its VGridOptionsRow.AllowMove option state.

Example

The following sample code sorts the “Software” child rows alphabetically in ascending order by their captions . The SortRows method searches the child rows list for the row with the smallest caption. It then moves this row to the front of the child row list. The VGridControlBase.MoveRow method is used for this purpose. Then it searches the remaining rows for the next smallest row, moves it into the list’s second position. The algorithm continues searching the shrinking list of unsorted rows, picking out the smallest and moving it to the end of the sorted section at the front of the child rows list. When it has moved every row into its final position, the algorithm stops.

The image below shows the result.

MoveRow - method

using DevExpress.XtraVerticalGrid.Rows;
// ...
private void SortRows(){
   for(int i = 0; i < Software.ChildRows.Count - 1; i++){
      BaseRow row = Software.ChildRows[i];
      for(int j = i; j < Software.ChildRows.Count - 1; j++){
         if (Software.ChildRows[j + 1].Properties.Caption.CompareTo(
         row.Properties.Caption) < 0){
            row = Software.ChildRows[j + 1];
         }
      }
      vGridControl1.MoveRow(row, Software.ChildRows[i], true);
   }
}
See Also