HI hab da noch eine Frage,
ich erstelle in Form1 das Tlabel2. Von der Form3 möchte ich mittels (form1.findcomponent('feld1') as tlabel2).caption darauf zugreifen bzw. auslesen. Jedoch wird die Komponente nicht gefunden, wenn ich es mit einem Label mache welches ich auf die Form platziere dann findet er es.
Woran könnte es liegen. Danke für die Hilfe.
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27:
| procedure TForm1.ToolButton1Click(Sender: TObject); var fstyle: string; begin
tl := tlabel2.Create(nil);
tl.name := 'feld'+inttostr(counter); tl.left := 200+counter*2; tl.top := 300+counter*4; tl.Caption := '<feld>'+inttostr(counter)+' '+tl.name; tl.Parent := form1; tl.autosize := true; tl.Transparent := true; tl.Hint := 'X:'+inttostr(tl.Left)+' Y:'+inttostr(tl.Top); tl.ShowHint := true;
tl.OnClick := tl.mouseclick;
inc(Counter);
end;
showmessage((form1.findcomponent('feld1') as TLabel2).caption); |
Danke für die Unterstützung