Ich habe ein neues Problem.
Auf einem 2. Formular habe ich eine TListview plaziert. Dort füge ich 600 Items ein. Dann Zeige ich das Formular an.
Mein Problem ist nun, dass das Anzeigen des 2. Formulars Ewig dauert und ich nicht verstehe wieso, bzw wie ich das wieder beschleunigen können soll.
Unten mal die relevanten Code Zeilen:
Code: Alles auswählen
Procedure TForm1.Button1Click(Sender: TObject);
Var
ti: Array[0..10] Of QWord;
t: QWord;
i: Integer;
li: Tlistitem;
s: String;
Begin
button1.enabled := false;
t := GetTickCount64;
form2.ListView1.BeginUpdate; // ich dachte immer das hilft beim einfügen, aber hier scheint es keinen Einfluss zu haben ...
form2.ListView1.Clear;
ti[0] := GetTickCount64 - t;
t := GetTickCount64;
For i := 0 To 600 Do Begin
li := Form2.ListView1.items.add();
li.Caption := 'Hallo ' + inttostr(i);
li.SubItems.Add('x');
li.SubItems.Add('y');
End;
ti[1] := GetTickCount64 - t;
t := GetTickCount64;
form2.ListView1.EndUpdate; // Auch das End update dauert 0ms
ti[2] := GetTickCount64 - t;
t := GetTickCount64;
form2.Show; // Dieses Form Show dauert bei mir mindestens 9s
ti[3] := GetTickCount64 - t;
t := GetTickCount64;
s := '';
For i := 0 To 3 Do Begin
s := s + inttostr(ti[i]) + LineEnding;
End;
label1.caption := s;
button1.enabled := true;
End;
Wie immer das gesammt Beispiel Projekt im Anhang