Skip to content

TStringList

Standard implementation of the TStrings class.

Declaration

Source position: classesh.inc line 1219

type

  TStringList = class(TStrings)
  public
    constructor Create;
    constructor Create(anOwnsObjects: Boolean);
    destructor Destroy;
    function Add : Integer;
    function AddObject : Integer;
    procedure Clear;
    procedure Delete;
    procedure Exchange;
    function Find : Boolean;
    function IndexOf(const S: string) : Integer; overload;
    function IndexOf(const S: string; aStart: Integer) : Integer; overload;
    procedure Insert;
    procedure Sort;
    procedure Sort(SortingAlgorithm: PSortingAlgorithm);
    procedure CustomSort(CompareFn: TStringListSortCompare);
    procedure CustomSort(CompareFn: TStringListSortCompare; 
                    SortingAlgorithm: PSortingAlgorithm);
    property Duplicates: TDuplicates; {rw}
    property Sorted: Boolean; {rw}
    property CaseSensitive: Boolean; {rw}
    property OnChange: TNotifyEvent; {rw}
    property OnChanging: TNotifyEvent; {rw}
    property OwnsObjects: Boolean; {rw}
    property SortStyle: TStringsSortStyle; {rw}
  end;

Description

TStringList is a descendant class of TStrings that implements all of the abstract methods introduced there. It also introduces some additional methods:

  • Sort the list, or keep the list sorted at all times
  • Special handling of duplicates in sorted lists
  • Notification of changes in the list

Properties

Member Visibility Description
CaseSensitive public Indicates whether comparing strings happens in a case sensitive manner.
Duplicates public Describes the behaviour of a sorted list with respect to duplicate strings.
OwnsObjects public Determines whether the stringlist owns it's objects or not.
Sorted public Determines whether the list is sorted or not.
SortStyle public Sort style for strings.
See all Properties

Methods

Member Visibility Description
Add public Implements the TStrings.Add function.
AddObject public
Clear public Implements the TStrings.Clear function.
Create public
CustomSort public Sort the stringlist using a custom sort algorithm.
Delete public Implements the TStrings.Delete function.
Destroy public Destroys the stringlist.
Exchange public Implements the TStrings.Exchange function.
Find public Locates the index for a given string in sorted lists.
IndexOf public Overrides the TStrings.IndexOf property.
Insert public Overrides the TStrings.Insert method.
Sort public Sorts the strings in the list.
See all Methods

Events

Member Visibility Description
OnChange public Event triggered after the list was modified.
OnChanging public Event triggered when the list is about to be modified.
See all Events

See also

Name Description
TStrings Class to manage arrays or collections of strings.
TStringList.Duplicates Describes the behaviour of a sorted list with respect to duplicate strings.
TStringList.Sorted Determines whether the list is sorted or not.