F
fei_xr
Unregistered / Unconfirmed
GUEST, unregistred user!
急死我了,我编写一个继承自TEdit的控件,增加一个属性“HeadNum”,希望在设计时通过Object Inspector进行设置,设置的值显示的编辑框中,可我写的代码不能显示值,却显示控件的名称:
unit BodyCard;
interface
uses
SysUtils, Classes, Controls, StdCtrls;
type
TBodyCard = class(TEdit)
private
{ Private declarations }
FHeadNum : String;
procedure keypress(var key: char);override;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
constructor Create(AOwner:TComponent);override;
property HeadNum : String read FHeadNum write FHeadNum;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('fei', [TBodyCard]);
end;
constructor TBodyCard.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
Text := FHeadNum;
//我在这里处理值的显示
end;
procedure TBodyCard.keypress(var key: char);
begin
inherited KeyPress(key);
if not(key in ['0'..'9','x','X',#8])then
key := #0;
end;
end.
unit BodyCard;
interface
uses
SysUtils, Classes, Controls, StdCtrls;
type
TBodyCard = class(TEdit)
private
{ Private declarations }
FHeadNum : String;
procedure keypress(var key: char);override;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
constructor Create(AOwner:TComponent);override;
property HeadNum : String read FHeadNum write FHeadNum;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('fei', [TBodyCard]);
end;
constructor TBodyCard.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
Text := FHeadNum;
//我在这里处理值的显示
end;
procedure TBodyCard.keypress(var key: char);
begin
inherited KeyPress(key);
if not(key in ['0'..'9','x','X',#8])then
key := #0;
end;
end.