Skip to main content

GridBandCollection.MoveTo(Int32, GridBand) Method

Moves a band to a new position among other bands.

Namespace: DevExpress.XtraGrid.Views.BandedGrid

Assembly: DevExpress.XtraGrid.v24.1.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

public virtual void MoveTo(
    int newIndex,
    GridBand band
)

Parameters

Name Type Description
newIndex Int32

An integer value representing a new position of a band within the collection.

band GridBand

A GridBand object representing the band to be moved.

Remarks

If the newIndex parameter exceeds the number of elements in the collection, the band is moved to the end of the collection. If the parameter value is negative, the band is removed.

Calling the MoveTo method is not in effect in the following cases:

  • the band doesn’t belong to the collection;
  • the newIndex parameter matches the index of the specified band.

When you move a band forward (i.e., when the newIndex is higher than the current index), the band is actually moved to the position specified by the newIndex - 1 value. When you move a band backward, the band is moved to the position specified by the newIndex value.

The following code moves a GridBand1 to the position after a GridBand3.

bandedGridView1.Bands.MoveTo(gridBand3.Index + 1, gridBand1);
See Also