Tcollection in Delphi

Source: Internet
Author: User
Tcollection is a container of the tcollectionitenm object.
Class relation tobject → tpersistent

Each tcollection has a set of tcollectionitem objects.
In its items attribute array, tccllection saves a subscript of the collection item. The Count attribute contains the number of items in the set. You can add a project to or delete a project from the collection by using the ADD and clear methods.
Objects inherited from tcollection can contain objects inherited from tcollectionitem. For example, a tdbgridcolumns object contains a tcolumn object, which is used by the TDBGrid object to represent the grid. The following table lists the child classes of each tcollection object and the Child classes of the corresponding tcollectionltem object and the use control components. The controls used by tqurytableproducer and twehdispetcher inherit from the twincontril object.

Tcollection subclass tcollectionitem subclass Control Component

Tcheckconstraints tcheckconstraint
Tcookiecollection tcookie HTTP Response object
Tcoolbands tcoolband tcoolbar
Tdbgridcolumns tcolumn TDBGrid
Tdependencies tdependency tservice
Tdisplaydims tdisplaydim tdecisiongrid
Tfielddefs tfielddef tdatsset
Theadersections theadersection theadercontrol
Tindexdefs tindexdef tTable
Thtmltablecolumns thtmltablecolumn tquerytableproducer
Tlistcolumns tlistcolumn tlistview
Tsuatuspanels tsuatuspanel tstatusbar
Twebactionitems twebactionitem twebdispatcher

Controls that use the tcollection and tcollectionitem sub-classes have a public attribute with a Set of 5 (for example, the Panels attribute of the tstatusbar has a tstatusanels ). A standard Attribute Editor is considered a collection editor in terms of species. It is introduced from the object inspector to edit projects in the set.

Attribute list
Count returns the number of items in the set.
Itemclass indicates that the collection project has a type.
Items provides access to the address change of items in the Set

Method list
~ Tcollection deletes a collection and each item in it.
Add creates an object instance and adds it to the items attribute array.
Assign copies the content of another set to the object that executes this method.
Bcginupdate pause screen update
Clear deletes all items from the collection
Endupdate enables the screen to be updated again
Finditemid: return the project specified by the ID parameter.
Insert creates a tcollectionitem object and adds it to the items attribute array.
Create and initialize a tcollection

Attribute
Tcollection: Count
Returns the number of items in the set.
_ Property int COUNT = {READ = getcount, nodefanlt };
The Count attribute contains the number of items in the items attribute array. Because the subscript of the items attribute array starts from 0, the Count attribute value is always 1 larger than the subscript of the last member of the items attribute array.

Tcollection: itemclass
Indicates the class of the collection project.
_ Property int COUNT = {READ = getxount, nodefauit };
Itemclass returns the class of the project that belongs to the Set (inherited from the tcolliectionitem object ). For example, if the tcollection object theadersections has an instance, the ietmclass attribute returns theadersection.

Tcollection: Items
Provides access to the address change of items in the set.
_ Property tcollectionitem * irems {int index} = {READ = getitem, write = setitem };
You can use the items attribute to access a single project in the set. The value of the index parameter corresponds to the index attribute of the tcollectionitem object. It indicates that the project has a position in the set.

Method
Tcollection ::~ Tcollection
Delete a collection and each project in it.
_ Fastcall virtual ~ Tcollection (void );
Do not directly call ~ Tcollection is automatically called using Delete ~ Tcollection
~ Tcollection calls the clear method to release the items referenced by each quilt in the items attribute array, and then deletes the collection.

Tcollection: add

Create a new tcollectionitem object instance and add it to the items attribute array.
Tcollectionitem * _ fasteall add (void );
Call add to create a project in the set. The new project is placed at the end of the items attribute array. Add returns the new collection project.

Tcollection: assign
Copy the content of another set to the object that executes this method.
Virtual void _ fastcall assign (tpersistemt * Source );
With assign, you can copy the content of a tcollection object instance to another tcollection object. The Assign Method deletes all projects in the target set (that is, the objects that execute this method), and then adds the copy of each project in the items attribute array of the set specified by the source parameter.

Tcollection: beginupdate
Pause screen update.
Void _ fastcall beginupdate (void );
Beginupdate pauses screen update until the endupdate method is called. You can use beginupdate to accelerate processing. You can avoid blinking when adding a project to or deleting a project from a collection.

Tcollection: endupdate
Delete all items from the collection.
Void _ fastcall ciear (void );
Ciear clears the items attribute array and deletes each tcollectionitem object.

Tcollection: endupdate
Enables the screen to be updated again.
Void _ fastcall endupdate (void );
Endupdate can be used to update the screen that is disabled by the beginupdate method.

Tcollection: finditemid
Returns the project specified by the ID parameter.
Tcollectionitem * _ fastcall finditemid (int id );
The finditemid method returns the project in the set. The ID attribute of the Project is passed as a parameter. If no item is specified by the ID parameter, finditemid returns NULL.

Tcollection: insert
Create a new tcollectionitem object instance and add it to the items attribute array.
Tcollectionitem * _ fastcall insert (INT index );
You can call insert to add a new project at a specified position in the set. Items that already exist in the items attribute array starting from the specified position will move up. Insert returns the new collection item.

Tcolletion: tcollection
Creates and initializes a set.
_ Fastcall tcollection (sysem: tmetaciass * itemciass );
Do not directly call tcollection. Using new will return an indirect reference to the new set.
The tcollection method uses a tcollectionitem subclass name as a parameter. This parameter determines the class of the project created by the add method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.