继承TPanel写个类TPanel1,在上面放上一个TEdit。
type
TPanel1 = class(TPanel)
private
FEdit:Tedit;
protected
public
constructor Create(AOwner: TComponent);override;
destructor Destroy;override;
published
property Edit: TEdit read FEdit write FEdit;
end;
.........
constructor TPanel1.Create(AOwner: TComponent);
begin
inherited;
FEdit := TEdit.Create(Self);
FEdit.SetSubComponent(True);
FEdit.Height := 16;
FEdit.Width := 60;
FEdit.Parent := Self;
end;
destructor TPanel1.Destroy;
begin
FEdit.Free;
inherited;
end;
我想在Edit的事件中写程序,可是双击Edit的事件时提示
cannot creat a method for an unnamed component.
请问如何解决这个问题。
或者我想自定义一个TPanel1事件(比如OnEditKeyPress)来相应Edit的这一事件(OnKeyPress),又该如何写。
type
TPanel1 = class(TPanel)
private
FEdit:Tedit;
protected
public
constructor Create(AOwner: TComponent);override;
destructor Destroy;override;
published
property Edit: TEdit read FEdit write FEdit;
end;
.........
constructor TPanel1.Create(AOwner: TComponent);
begin
inherited;
FEdit := TEdit.Create(Self);
FEdit.SetSubComponent(True);
FEdit.Height := 16;
FEdit.Width := 60;
FEdit.Parent := Self;
end;
destructor TPanel1.Destroy;
begin
FEdit.Free;
inherited;
end;
我想在Edit的事件中写程序,可是双击Edit的事件时提示
cannot creat a method for an unnamed component.
请问如何解决这个问题。
或者我想自定义一个TPanel1事件(比如OnEditKeyPress)来相应Edit的这一事件(OnKeyPress),又该如何写。
解决方案 »
- MediaPlayer控件的显示模式
- delphi 多线程 界面 卡住的问题 ,求高手 帮助!
- 如何实现一个自定义的RichEdit控件
- 有一个strpcopy问题,向大家请教
- dll中创建的组件,在主窗体上显示不出来?
- SQL-SERVER PROCEDURE与DELPHI的调用问题
- 高分求解:一个奇怪的SQL查询!
- 兄弟们,帮忙,愚人节怎么耍人有创意????
- stringgird 中每个小格,或每一行 字体或背景色变成红色
- delphi treeview 控件如何数据竖向居中显示就像二叉树一样首节点最上方居中子节点依次在下方
- 如何将字符串转换为字节数组,反之,如何将字节数组转换为字符串?(即时结贴)
- 我的课件给老师损的一文不值,真的这么垃圾么,大家帮忙看看,给点意见,伤心中
FEdit := TEdit.Create(Self);
后加上:
FEdit := 'PanelEdit1'; //或者其他名字另:
property Edit: TEdit read FEdit write FEdit;
应该为
property Edit: TEdit read FEdit;因为Edit是内部创建的,在外部不应该能修改。
————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————
如果自定义一个TPanel1事件(比如OnEditKeyPress)来相应Edit的这一事件(OnKeyPress),该如何解决。
CDSoftwareWj(95927) :最近工作太忙:)private
FEdit: TEdit;
procedure SetOnEditKeyPress(Value: TKeyPressEvent);
function GetOnEditKeyPress: TKeyPressEvent;
published
property Edit: TEdit read FEdit;
property OnEditKeyPress: TKeyPressEvent read GetOnEditKeyPress write SetOnEditKeyPress;
end;
procedure TPanel1.SetOnEditKeyPress(Value: TKeyPressEvent);
begin
if FEdit <> nil then
FEdit.OnKeyPress := Value;
end;function TPanel1.GetOnEditKeyPress: TKeyPressEvent;
begin
Result := nil;
if FEdit <> nil then
Result := FEdit.OnKeyPress;
end;————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————