开发者

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

开发者 https://www.devze.com 2023-02-01 06:59 出处:网络
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 t

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号