[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Classes' (#rtl)

TStrings.Move

Move a string from one place in the list to another.

Declaration

Source position: classesh.inc line 684

public procedure TStrings.Move(

  CurIndex: Integer;

  NewIndex: Integer

); virtual;

Description

Move moves the string at position CurIndex so it has position NewIndex after the move operation. The object associated to the string is also moved. CurIndex and NewIndex should be in the range of 0 to Count-1.

Remark:

NewIndex is not the position in the stringlist before the move operation starts. The move operation

  1. removes the string from position CurIndex
  2. inserts the string at position NewIndex

This may not lead to the desired result if NewIndex is bigger than CurIndex. Consider the following example:

With MyStrings do
    begin
    Clear;
    Add('String 0');
    Add('String 1');
    Add('String 2');
    Add('String 3');
    Add('String 4');
    Move(1,3);
    end;

After the Move operation has completed, 'String 1' will be between 'String 3' and 'String 4'.

Errors

If either CurIndex or NewIndex is outside the allowed range, an EStringListError is raised.

See also

TStrings.Exchange

  

Exchanges two strings in the list.


Documentation generated on: Nov 16 2015