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 = class(TCollectionItem)
private
fId: Integer;
function GetId: Integer;
public
published
property Id: Int开发者_开发百科eger read GetId;
end;
function TCVSClassItem.GetId: Integer;
begin
result:= ????
end;
result := Index+1 should do it if I understand correctly your needs
精彩评论