 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Andrejs Shtrumfs Guest
|
Posted: Tue Jul 22, 2003 2:05 pm Post subject: TCollectionItem descendant problem |
|
|
Hi All!
I have created a custom grid with columns (TCollectionItem descendant)
stored in TCollection descendant. The columns have some published
properties and events. All is working well unless i try to make a
descendand from form that contains my grid with assigned events in
columns. The error is access violation at address 4002D847. After
little digging i found that it is line 6005 (TWriter.WriteProperty) in
Classes.pas:
Result := (Value.Code = DefaultCode) or
((Value.Code <> nil) and (FLookupRoot.MethodName(Value.Code) =
''));
Looks like when trying to save the event handler to dfm the
FLookupRoot is nil. So first thing i wanted to say is that inability
to debug the vcl code in designtime is really big problem for me.
Maybe someone knows the solution for this? And second, where is the
problem with my code? Or it is a bug in Delphi?
interface
TDCGrid = class(TStringGrid)
private
FColumns: TDCGridColumnCollection;
procedure SetColumns(const Value: TDCGridColumnCollection);
published
property Columns: TDCGridColumnCollection read FColumns write
FColumns;
end;
TDCGridColumnCollection = class(TOwnedCollection)
public
FGrid: TDCGrid;
end;
TDCGridColumn = class(TCollectionItem)
private
FOnChoose: TChooseEvent;
public
function GetNamePath: string; override;
procedure Assign(Source: TPersistent); override;
protected
function GetDisplayName: string; override;
procedure SetDisplayName(const Value: string); override;
published
property OnChoose: TChooseEvent read FOnChoose write FOnChoose;
end
implementation
function TDCGridColumn.GetNamePath: string;
begin
result := TDCGridColumnCollection(Collection).FGrid.Name + '.' +
TDCGridColumnCollection(Collection).PropName + '.' + FName;
end;
procedure TDCGridColumn.Assign(Source: TPersistent);
begin
if Source is TDCGridColumn then
begin
if Assigned(Collection) then Collection.BeginUpdate;
try
//.....
OnChoose := TDCGridColumn(Source).OnChoose;
finally
if Assigned(Collection) then Collection.EndUpdate;
end;
end
else
inherited Assign(Source);
end;
function TDCGridColumn.GetDisplayName: string;
begin
result := FName;
if Result = '' then result := inherited GetDisplayName;
end;
procedure TDCGridColumn.SetDisplayName(const Value: string);
begin
if FName <> Value then
FName := Value;
end;
Thanks
Andrejs Shtrumfs
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|