Registriert seit: 15. Jun 2010
Ort: Augsburg Bayern Süddeutschland
3.470 Beiträge
Delphi XE3 Enterprise
|
AW: TLabeledEdit ableiten
12. Jun 2012, 16:25
versuch mal ob das das ist was Du suchst ...
Delphi-Quellcode:
TLabeledEditNumeric = class(TLabeledEdit)
private
function GetText: TCaption; reintroduce;
protected
FValue: Integer;
FMin: Integer;
FMax: Integer;
FInc: Integer;
procedure SetValue(value: Integer);
procedure SetText(const Value: TCaption); reintroduce;
public
published
property Value: Integer read FValue write SetValue;
property Min: Integer read FMin write FMin;
property Max: Integer read FMax write FMax;
property Increment: Integer read FInc write FInc;
Property Text:TCaption read GetText Write SetText;
end;
TForm5 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form5: TForm5;
implementation
{$R *.dfm}
function TLabeledEditNumeric.GetText: TCaption;
begin
Result := inherited text;
end;
procedure TLabeledEditNumeric.SetText(const Value: TCaption);
var
i:Integer;
begin
if TryStrToInt(Value,i) then
begin
inherited Text := value;
FValue := i;
end;
end;
procedure TLabeledEditNumeric.SetValue(value: Integer);
begin
FValue := value;
Text := IntToStr(FValue);
end;
procedure TForm5.Button1Click(Sender: TObject);
begin
With TLabeledEditNumeric.Create(self) do
begin
Text:='Haus';
Showmessage(Text);
Text:='1';
Showmessage(Text);
Text:='Haus';
Showmessage(Text);
end;
end;
Thomas Wassermann H₂♂ Das Problem steckt meistens zwischen den Ohren
DRY DRY KISS
H₂♂ (wenn bei meinen Snipplets nichts anderes angegeben ist Lizenz: WTFPL)
|