Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi LabelPanel dringend gesucht! (https://www.delphipraxis.net/16199-labelpanel-dringend-gesucht.html)

Tpercon 12. Feb 2004 15:31

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;

nemo2003 12. Feb 2004 15:41

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;

Tpercon 12. Feb 2004 15:45

Re: LabelPanel dringend gesucht!
 
Ich würde mich mal nur in dem SetItems um die Labels kümmern:
Delphi-Quellcode:
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;
So steuerst du das ganze:
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.
Seite 2 von 2     12   

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