Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Listview an der Anzahl von Symbole anpassen? (https://www.delphipraxis.net/91976-listview-der-anzahl-von-symbole-anpassen.html)

smart 12. Mai 2007 16:32


Listview an der Anzahl von Symbole anpassen?
 
Hallo Alle!

Ich habe eine Form mit Listview daruf. Im Listview sind ab und zu mal 4 Symbole oder auch 16. Wie kann ich die Form und Listview dazu veranlassen, dass sie sich der Größe je nach Anzahl der Symbole anpasst?

Gruß
Heike

bitsetter 12. Mai 2007 21:08

Re: Listview an der Anzahl von Symbole anpassen?
 
So ähnlich könnte man es wohl machen:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  loop : integer;
  ItemRect: TRect;
  MaxWidth, MaxHeight : integer;
begin
  MaxWidth := 0;
  MaxHeight := 0;
  for loop := 0 to pred(ListView1.Items.Count) do
  begin
    ItemRect := ListView1.Items.Item[loop].DisplayRect(drBounds);
    if ItemRect.Right > MaxWidth then
      MaxWidth := ItemRect.Right;
    if ItemRect.Bottom > MaxHeight then
      MaxHeight := ItemRect.Bottom;
  end;
  inc(MaxWidth, 4);//wegen Scrollbar
  inc(MaxHeight, 4);
  //Form anpassen
  Listview1.Parent.Width := Listview1.Parent.Width - Listview1.ClientWidth + MaxWidth;
  Listview1.Parent.Height := Listview1.Parent.Height - Listview1.ClientHeight + MaxHeight;
  //Listview Abmessung anpassen
  Listview1.ClientWidth := MaxWidth;
  Listview1.ClientHeight := MaxHeight;
end;

smart 13. Mai 2007 18:15

Re: Listview an der Anzahl von Symbole anpassen?
 
Zitat:

Zitat von bitsetter
So ähnlich könnte man es wohl machen:

Vielen Dank, für Deine Hilfe und noch einen schönen Sonntag.

Gruß
Heike


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:58 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