TSubstringList.InsertObject Method

procedure InsertObject(const Index: Integer; const S: string; const AObject: TObject); overload;

Inserts S with the object AObject at Index, as Insert.

#NameDescription
1Index

The new item's index, 0..Count.

2S

The text, every text kind.

3AObject

The item's object; with OwnsObjects the list frees it.

Result: stored in self (calling object)

Examples

An item with its object, at the front.

uses Substr;

procedure Example;
var List: TSubstringList;
begin
    List := TSubstringList.Create(4);
    try
        List.Add('b');
        List.InsertObject(0, 'a', List);
        Assert((List[0] = 'a') and (List.Objects[0] = List));
        Assert(List.Objects[1] = nil);
    finally
        List.Free;
    end;
end;
See Also: TSubstringList.Insert, TSubstringList.Objects