![]() |
Re: LabelPanel dringend gesucht!
Hier mal ein grober Anfang der Klasse.
Delphi-Quellcode:
TLabelPanel = class(TCustomPanel)
private FLabels: TObjectList; FItems: TStrings; procedure SetItems(Value: TStrings); public constructor Create(aOwner : TComponent); override; destructor Destroy; override; property Items: TStrings read FItems write SetItems; end; |
Re: LabelPanel dringend gesucht!
und die .create methode eta so, richtig?
dann bin ich auf dem richtigen dampfer...
Delphi-Quellcode:
procedure TLabelPanel.CreateLabels(aValues:TStringList);
var count:integer; DaLabel:TLabel; begin for count:=0 to aValues.Count do begin DaLabel:=TLabel.create(nil); DaLabel.Caption:=aValues.Strings[count]; // etc... end; end; |
Re: LabelPanel dringend gesucht!
Ich würde mich mal nur in dem SetItems um die Labels kümmern:
Delphi-Quellcode:
So steuerst du das ganze:
constructor TMultiLinePanel.Create(aOwner: TComponent);
begin inherited Create(aOwner); FLabels := TObjectList.Create(true); FItems := TStringList.Create; end; destructor TMultiLinePanel.Destroy; begin if Assigned(FLabels) then begin FLabels.Free; end; if Assigned(FItems) then begin FItems.Free; end; inherited Destroy; end; procedure TMultiLinePanel.SetItems(Value: TStrings); var aLabel : TLabel; i : integer; begin FLabels.Clear; for i := 0 to Value.Count - 1 do begin; aLabel := TLabel.Create(nil); aLabel.Parent := self; aLabel.AutoSize := true; aLabel.Top := self.Height div (Value.Count + 1) * (i + 1); aLabel.Left := 8; aLabel.Caption := Value.Strings[i]; FLabels.Add(aLabel); end; FItems.Text := Value.Text; end;
Delphi-Quellcode:
MyPanel := TMultiLinePanel.Create(self);
MyPanel.Parent := self; ts := TStringList.Create; try ts.Add('bla'); ts.Add('blubb'); MyPanel.Items := ts; finally ts.Free; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:29 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 by Thomas Breitkreuz