src/Misc/EFTools/DesignXmlCore/VirtualTreeGrid/Provider/ColumnPermutation.cs
/// <summary>
///     Method to change the order of the columns in the permutation
///     without fully recreating a new permutation. The indices are given
///     in visible columns.
/// </summary>
/// <param name="column">The column to move</param>
/// <param name="newLocation">The new location</param>
Method to change the order of the columns in the permutation
without fully recreating a new permutation. The indices are given
in visible columns.
Method to change the order of the columns in the permutation without fully recreating a new permutation . The indices are given in visible columns .
public void MoveVisibleColumn(int column, int newLocation)
        {
            int moveNativeColumn;
            int newNativeColumn;
            if (column < newLocation)
            {
                moveNativeColumn = myVisibleColumns[column];
                for (var i = column; i < newLocation; ++i)
                {
                    newNativeColumn = myVisibleColumns[i + 1];
                    myVisibleColumns[i] = newNativeColumn;
                    myColumns[newNativeColumn] = i;
                }
                myColumns[moveNativeColumn] = newLocation;
                myVisibleColumns[newLocation] = moveNativeColumn;
            }
            else if (column > newLocation)
            {
                moveNativeColumn = myVisibleColumns[column];
                for (var i = column; i > newLocation; --i)
                {
                    newNativeColumn = myVisibleColumns[i - 1];
                    myVisibleColumns[i] = newNativeColumn;
                    myColumns[newNativeColumn] = i;
                }
                myColumns[moveNativeColumn] = newLocation;
                myVisibleColumns[newLocation] = moveNativeColumn;
            }
        }
public void MoveVisibleColumn ( int column , int newLocation ) { int moveNativeColumn ; int newNativeColumn ; if ( column < newLocation ) { moveNativeColumn = myVisibleColumns [ column ] ; for ( var i = column ; i < newLocation ; ++ i ) { newNativeColumn = myVisibleColumns [ i + 1 ] ; myVisibleColumns [ i ] = newNativeColumn ; myColumns [ newNativeColumn ] = i ; } myColumns [ moveNativeColumn ] = newLocation ; myVisibleColumns [ newLocation ] = moveNativeColumn ; } else if ( column > newLocation ) { moveNativeColumn = myVisibleColumns [ column ] ; for ( var i = column ; i > newLocation ; -- i ) { newNativeColumn = myVisibleColumns [ i - 1 ] ; myVisibleColumns [ i ] = newNativeColumn ; myColumns [ newNativeColumn ] = i ; } myColumns [ moveNativeColumn ] = newLocation ; myVisibleColumns [ newLocation ] = moveNativeColumn ; } }
Method to change the order of the columns in the permutation
without fully recreating a new permutation.
Method to change the order of the columns in the permutation without fully recreating a new permutation .
column
int
The column to move
The column to move
newLocation
int
The new location
The new location