Questions tagged [tcollectionitem]

TCollectionItem represents an item in a TCollection. It is defined in the Classes.pas unit.

17 questions
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
4
votes
2 answers

Change the label of a TCollectionItem in the Delphi editor

A component I am working on uses a TCollection to hold links to other components. When the items are edited in the designer their labels look something like this: 0 - TComponentLink 1 - TComponentLink 2 - TComponentLink 3 - TComponentLink How do I…
norgepaul
  • 6,013
  • 4
  • 43
  • 76
2
votes
1 answer

TCollectionItem and destructor method in delphi

Hey, Could anyone tell me if the implementations of the Destructor in the following example are correct and the same? TTaskItem = class (TCollectionItem) private FTask: TTask; public constructor Create(Collection:…
Paul
  • 35
  • 3
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

Event in descendant of TCollectionItem

I wrote simple code (see below): a descendant of TCollectionItem with an event. But when I click OnDone event in object inspector I get the message: "Cannot create a method for an unnamed component". What is wrong with this code? unit…
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
vote
1 answer

Delphi: How to allow setting a TClass-property of a TCollectionItem at design time

I'm developing a component that works on several classes. In order to allow adding the list of managed classes, I've written a TCollection's inherited class in which each item (inherited from TCollectionItem) defines a published "TargetClassName"…
Hwau
  • 850
  • 3
  • 12
  • 23
1
vote
1 answer

TColumn.FieldName property editor

I'm analyzing the DBGrids.pas unit. There's a TColumn class which have published the FieldName property property FieldName: String read FFieldName write SetFieldName; It's declared as a string but in the object inspector it's appear as a editable…
JustMe
  • 2,329
  • 3
  • 23
  • 43
1
vote
1 answer

how to change ItemClass of a class inherited from TCollection

I have a class which inherited from TCollection (lets call it "TMyCollection") and I have to inherit a new class from it (lets call it "TMyItems") Usually we pass the ItemClass type in the constructor of the TCollection but in my case the…
user1512094
  • 611
  • 2
  • 10
  • 23
0
votes
1 answer

TCollectionItem not initializing default property values

I've been fighting this crazy problem for hours and have gotten nowhere. I have this problem in two completely different projects using a TCollection. When a new collection item is added, I need to initialize the values of that item. However,…
Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
0
votes
0 answers

Adding Events to TCollectionItem with C++ Builder 5

My question is simple : How to implement an event handling within a TCollection or TCollectionItem ? When I simply add a TNotifyEvent to a TCollection Item, no compile error... But at design time... a bad declaration error occurs... I have tried on…
0
votes
1 answer

No reaction when "..." clicked on a TCollectionItem property that represents another TCollection

I've never been in a situation that needed it, and this is the first time I try to have a TCollection as TCollectionItem of another TCollection. It all compiles fine, but there is no reaction when the three dots behind the TCollectionItem's…
Domus
  • 1,263
  • 7
  • 23
0
votes
1 answer

How to add a 2-times derived class of TCollectionItem to TOwnedCollection?

I want to implement a collection or list using TOwnedCollection / TCollectionItem. I need a persistent list (to load and create from a FileStream) of classes with polymorphism. Here is (part of) my code so far, but I didn't succeed to create the…
Lotfi
  • 660
  • 1
  • 6
  • 21
1
2