Questions tagged [tcollection]

TCollection is a container for TCollectionItem objects. It is defined in the Classes.pas unit.

24 questions
8
votes
2 answers

The Fastest Way to Load an Array DML in Delphi FireDAC

I am using Delphi XE8 with FireDAC to load a large SQLite database. To do so, I'm using the Array DML execution technique to efficiently insert a large number of records at once, like this: FDQueryAddINDI.SQL.Text := 'insert into indi values (' +…
lkessler
  • 19,819
  • 36
  • 132
  • 203
6
votes
3 answers

Creating a component with named sub-components?

I need to know the basics behind making a component produce and manage sub-components. I originally tried this by creating a TCollection, and tried to put a name on each TCollectionItem. But I learned it's not that easy as I had hoped. So now I am…
Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
4
votes
3 answers

How do I reorder items in a TCollection?

I am trying to implement MoveItemUp and MoveItemDown methods that move a selected row up or down one index within a TCollection. The following code added to my subclass of TCollection does not work: procedure TMyCollection.MoveRowDown(index:…
Warren P
  • 65,725
  • 40
  • 181
  • 316
3
votes
3 answers

Persistent Polymorphic Lists in Delphi

I need a list of polymorphic objects (different object classes, but with a common base class) that I can 'persist' as part of a form file. TList isn't persistent, and TCollection isn't polymorphic. I can probably roll my own but prefer not to…
Roddy
  • 66,617
  • 42
  • 165
  • 277
3
votes
1 answer

for all/for each looping through a Delphi TCollection?

Does Delphi provide any nice way to iterate over TCollectionItems in a TCollection? Something, perhaps, along the lines of... for mycollectionitem in mycollection.Items do mycollectionitem.setWhatever(); That doesn't compile though or is there…
Jessica Brown
  • 8,222
  • 7
  • 46
  • 82
2
votes
1 answer

Delphi TCollection - Possible to prevent changing items in run-time?

Using delphi 7, I have a TCollection/TCollectionItem set of descendents. They are intended to be set up in Design-time only, and should never be modified in Run-time. How can I do this? Design-time should always allow whatever edits are needed, but…
Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
2
votes
1 answer

Saving vcl objects references in dephi with Tcollection

I am using delphi 2009 and VCL components. I have created a collection called TStreets made of items TStreet which has just two private fields. Now I need to add to Tstreet class another field/property to keep track (by using reference) of other…
marcostT
  • 573
  • 1
  • 10
  • 20
2
votes
1 answer

Cannot override TCollection.Notify: Declaration of Notify differs from previous declaration

Note: The title of other question is different which prevents it from identifying as the matching one. System.Classes TCollection = class(TPersistent) protected procedure Notify(Item: TCollectionItem; Action: TCollectionNotification);…
Paul
  • 25,812
  • 38
  • 124
  • 247
2
votes
1 answer

Getting the index # of a TCollection Item when added to a TCollection

I know that when I add a collection item to a collection, the index is zero-based. I would like to make it one-based and show the value in a property called Id. Can someone tell me how I can go about this in code? TCVSClassItem =…
IElite
  • 1,818
  • 9
  • 39
  • 64
2
votes
1 answer

return TCollection or array of objects from Dll

I tried to return from dll function my own object (derived from TCollection). I used FastMemoryManager, but without success... So I tried to return dynamic array of some objects. Length of the array of set of course in dll function. It works…
Peter
  • 269
  • 3
  • 13
1
vote
2 answers

Serialization of a TCollection which is not declared in a TComponent?

Is it possible to serialize a TCollection which is not encapsulated in a TComponent ? For example, I have a custom TCollection. I can't use TMemoryStream.WriteComponent() on my TCollection descendant. It'll only works if I encapsulate the collection…
az01
  • 1,988
  • 13
  • 27
1
vote
1 answer

Converting collections to 'named components' - compiler error

This is specifically related to the accepted answer of another question I asked. During conversion of my already-existing collections to this new 'named collection item' structure (as explained in the previous question), I came across a compiler…
Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
1
vote
1 answer

TOwnedCollection and using multiple inherited TCollectionItem

I'm having problems adding my own TCollectionItem classes (inherited from TCollectionItem) within the same TOwnedCollection. I referred to Indy's IdMessageParts.pas for TIdMessagePart as recommended. So I must be missing something as I get a…
Peter Jones
  • 451
  • 2
  • 12
1
vote
2 answers

Recursive read of TCollection

I'm very bad with recursion, never used it before. I know the theory of it .. not that that helps :)) For my problem i have a structure of TCollection that contains TCollection and TCollectionItem etc .. I have to write a recursion function that…
krizajb
  • 1,715
  • 3
  • 30
  • 43
1
vote
3 answers

Is it possible? TCollection descendant to implement storage of TPanel containers with arbitrary content

I'm new to component development in Delphi, therefore want to know, is it possible to implement my task at all. I need to create a visual component (user control) based on TScrollBox, which will represent a bunch of TPanel, all that panels will be…
Andrew
  • 3,696
  • 3
  • 40
  • 71
1
2