![]() |
Package compiliert nicht
Hi,
folgenden Code habe ich in ein Package einbauen wollen:
Code:
Delphi stört sich an dem SetDBLabel. Aber warum ? Da steht nur folgendes drin:
TDBLabeledEdit = class(TDBEdit)
private { Private declarations } FDBfeldLabel : TLabel; procedure SetDBLabel (st : string); protected { Protected declarations } public { Public declarations } constructor Create(AOwner: TComponent); override; destructor Destroy; override; published { Published declarations } property DBfeldLabel : TLabel read FDBfeldLabel write SetDBLabel; end;
Code:
Fehlermeldung : "incompatible types"
procedure TDBLabeledEdit.SetDBLabel (st : string);
begin FDBfeldLabel.Caption := 'st'; end; |
Re: Package compiliert nicht
Hallo Hansa,
Zitat:
Code:
Wäre vielleicht besser.
FDBfeldLabel.Caption := st;
Grüsse, Daniel :hi: |
muss das st nicht ohne die '' ?
Delphi-Quellcode:
procedure TDBLabeledEdit.SetDBLabel (st : string);
begin FDBfeldLabel.Caption := st; // ohne '' end; |
Hallo,
bin mir nicht sicher, aber hast Du im Objektinspektor deiner Eigenschaft "DBfeldLabel" einen Label zugeordnet? Könntest ja prüfen mit:
Delphi-Quellcode:
p.s.: ob 'st' oder st:String sollte keinen Fehler ausgeben, oder? (obwohl es nix bringt, 'st' zuzuweisen)
procedure TDBLabeledEdit.SetDBLabel (st : string);
IF Assigned(FDBfeldLabel) THEN BEGIN FDBfeldLabel.Caption := st; // 'st' END; |
das Problem ist nicht das st, sondern daß nicht compiliert wird.
|
Hallo,
probier mal das:
Delphi-Quellcode:
procedure TDBLabeledEdit.SetDBLabel(Const st : TLabel);
IF Assigned(FDBfeldLabel) THEN BEGIN FDBfeldLabel.Caption := st.Caption; END; |
nix.
Code:
kommentiere ich das
property DBfeldLabel : TLabel read FDBfeldLabel write SetDBLabel;
Code:
aus, wird compliliert. Also nicht die ganze Zeile.
write SetDBLabel
|
Code:
Tatsächlich wird jetzt compiliert. Aber warum :?: Im OI ist von der Sache trotzdem nichts zu sehen.
procedure TDBLabeledEdit.SetDBLabel(st : TLabel);
begin FDBfeldLabel.Caption := st.Caption; END; |
Naja,
weil Du im
Delphi-Quellcode:
DBfeldLabel als TLabel deklariert hast,
property DBfeldLabel : TLabel read FDBfeldLabel write SetDBLabel;
daher muß das Attribut
Delphi-Quellcode:
und der Schreibzugriff
FDBfeldLabel : TLabel;
Delphi-Quellcode:
vom gleichem Typ sein.
write SetDBLabel;
... procedure TDBLabeledEdit.SetDBLabel(st : TLabel); |
Wo Du Recht hast, hast Du Recht. 8) 8) Jetzt wird compiliert. Da ist aber noch was : DBfeldLabel ist jetz im OI. Aber an Caption etc. vom Label komm ich nicht dran.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:54 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz