Please take a look to the bellow code part of a TComponent
:
TMyField = class(TCollectionItem)
private
FName: String
FSqlField: TSqlField;
procedure SetName(const Value: String);
procedure SetSqlField(const Value: TSqlField)
published
property Name: String read FName write SetName;
property SqlField: TSqlField read FSqlField write SetSqlField;
end;
TSqlField = class(TPersistent)
private
FAlias: String;
FName: String;
FTable: String;
procedure SetField(Index: Integer; Value: String);
public
procedure Assign(Source: TPersistent); override;
published
property Alias: String index 0 read FAlias write SetField;
property Name: String index 1 read FName write SetField;
property Table: String index 2 read FTable write SetField;
end;
procedure TSqlField.SetField(Index: Integer; Value: String);
var
FOwner: TMyField;
begin
if (Value <> FAlias) or (Value <> FName) or (Value <> FTable) then
begin
case Index of
0: if Value <> FAlias then FAlias:= Value;
1: if Value <> FName then FName:= Value;
2: if Value <> FTable then FTable:= Value;
end;
if FName <> '' then
begin
FOwner:= GetOwner; //Error here: E2010 Incompatible types: 'TMyField' and 'TPersistent'
if FTable <> '' then FOwner.Name:= Format('%s_%s',[FTable,FName])
else FOwner.Name:= FName;
end;
end;
end;
When the method SetField
from TSqlField
is processed I would like to access the property Name
from TSqlField : TCollectionItem
so I can rename it.
Remark: The owner of TCollection
could be one or another TComponent
.
Please some suggestions about how can this be done.