A
awing
Unregistered / Unconfirmed
GUEST, unregistred user!
写了个类,继承至TCollectionItem,代码如下
TCustomCommand = class(TCollectionItem)
private
FCaption: string;
FData: String;
FOnExecute: TNotifyEvent;
protected
public
constructor Create(Collection: TCollection); override;
function Execute: Boolean;
property Caption: string read FCaption write FCaption;
property Data: string read FData write FData;
property OnExecute: TNotifyEvent read FOnExecute write FOnExecute;
published
end
constructor TCustomCommand.Create(Collection: TCollection);
begin
inherited Create(Collection);
end;
function TCustomCommand.Execute;
begin
if Assigned(FOnExecute) then
begin
FOnExecute(self);
Result := True;
end
else
Result := False;
end;
同时写了一个继承TCollection的类来调用它,主要想实现DBGrid的Column的那种功能
现在窗体也都能创建,item的编辑框也能跳出来,添加customcommand也能成功,也能
给属性赋值,但是当我想往OnExecute中添加代码的时候出错“Cannot create a method
for an unnamed component”,谁有写过类似的代码啊,帮帮我吧。
TCustomCommand = class(TCollectionItem)
private
FCaption: string;
FData: String;
FOnExecute: TNotifyEvent;
protected
public
constructor Create(Collection: TCollection); override;
function Execute: Boolean;
property Caption: string read FCaption write FCaption;
property Data: string read FData write FData;
property OnExecute: TNotifyEvent read FOnExecute write FOnExecute;
published
end
constructor TCustomCommand.Create(Collection: TCollection);
begin
inherited Create(Collection);
end;
function TCustomCommand.Execute;
begin
if Assigned(FOnExecute) then
begin
FOnExecute(self);
Result := True;
end
else
Result := False;
end;
同时写了一个继承TCollection的类来调用它,主要想实现DBGrid的Column的那种功能
现在窗体也都能创建,item的编辑框也能跳出来,添加customcommand也能成功,也能
给属性赋值,但是当我想往OnExecute中添加代码的时候出错“Cannot create a method
for an unnamed component”,谁有写过类似的代码啊,帮帮我吧。