This page is intended as a supplement to the official documentation on Delphi programming. CodeGear is in the process of putting the Delphi documentation on the Web. Once they have done so, this page will link to the relevant page in the official documentation.
This article is a stub.
Please help enhance the Delphi Programming Wiki by expanding it.
see the VCL Documentation Guidelines for an overview on doc pages

Unit[edit | edit source]

Hierarchy[edit | edit source]

Description[edit | edit source]

TObjectList expands Tlist by adding the option to take ownership for the Tobject items added to the list through the use of the "OwnsObjects" property. Setting "OwnsObjects" to true will allow the object list to free the memory for each item in the list when the Tobjectlist is freed or removed from the list. Basic methods from Tlist such as add, delete, rearrange, locate, access, and sort remain accessible.

Technical Comments[edit | edit source]

(Known issues / Documentation clarifications / Things to be aware of)

Examples[edit | edit source]

Procedure OwnedObjectDemo;
  MyObject: TObject;
  MyList: TObjectlist; 
  MyObject := TObject.Create;
  MyList := TObjectList.Create(True); // OwnsObjects is True.OwnsObjects by default is true so just MyList := TObjectList.Create; would be enough here.
  //operating code....
  MyList.Free; //MyObject is also freed since the TObjectList was created with the OwnsObjects property set to true. 

(Please provide links to articles/source code that show how to use this item.)

See Also[edit | edit source]

(Please provide links to items specifically related to this item.)

User Comments/Tips[edit | edit source]

(Please leave your name with your comment.)

Community content is available under CC-BY-SA unless otherwise noted.