Delphi-PRAXiS
Seite 4 von 6   « Erste     234 56      

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 Meine Drag'n'Drop-Funktion ergänzen (https://www.delphipraxis.net/149884-meine-dragndrop-funktion-ergaenzen.html)

Helmi 1. Apr 2010 21:18

Re: Meine Drag'n'Drop-Funktion ergänzen
 
Du solltest aber trotzdem mal deine Freigabe der List2 überdenken.
Delphi-Quellcode:
        List2:=Explode('=', List[i]);
        ListBox1.Items.Insert(i, List2[1]);
        ListBox2.Items.Insert(i, List2[2]);
        ListBox3.Items.Insert(i, List2[3]);
        ListBox4.Items.Insert(i, List2[4]);
        List2.Free;
//<--

DeddyH 1. Apr 2010 21:19

Re: Meine Drag'n'Drop-Funktion ergänzen
 
Trotzdem finde ich solchen Code etwas optimistisch:
Zitat:

Delphi-Quellcode:
List2:=Explode('<>', List[i]);
    ListBox1.Items.Insert(i, List2[1]);
    ListBox2.Items.Insert(i, List2[2]);
    ListBox3.Items.Insert(i, List2[3]);
    ListBox4.Items.Insert(i, List2[4]);
    List2.Free;

Du solltest nach dem Explode zumindest überprüfen, ob überhaupt mehr als 4 Elemente in der Liste stehen, das war vermutlich auch der Grund für den Fehler.

[edit] :lol: :cheers: [/edit]

AlexII 1. Apr 2010 21:19

Re: Meine Drag'n'Drop-Funktion ergänzen
 
Hm... was genau? Verzeih, bin Hobbyprogrammierer. :gruebel:

AlexII 1. Apr 2010 21:21

Re: Meine Drag'n'Drop-Funktion ergänzen
 
Ne der Fehler war deswegen, eine .crp Datei wird mit
Zitat:

List2:=Explode('<>', List[i]);
geladen und andere
Zitat:

List2:=Explode('=', List[i]);
und weil die Abfrage falsch war wurde die .crp mit "=" geladen, und das verursachte den Fehler.

DeddyH 1. Apr 2010 21:22

Re: Meine Drag'n'Drop-Funktion ergänzen
 
Delphi-Quellcode:
List2:=Explode('<>', List[i]);
try
  if List2.Count > 1 then
    ListBox1.Items.Insert(i, List2[1]);
  if List2.Count > 2 then
    ListBox2.Items.Insert(i, List2[2]);
  if List2.Count > 3 then
    ListBox3.Items.Insert(i, List2[3]);
  if List2.Count > 4 then
    ListBox4.Items.Insert(i, List2[4]);
finally
  List2.Free;
end;
Oder wenn alles erfüllt sein muss:
Delphi-Quellcode:
List2:=Explode('<>', List[i]);
try
  if List2.Count > 4 then
    begin
      ListBox1.Items.Insert(i, List2[1]);
      ListBox2.Items.Insert(i, List2[2]);
      ListBox3.Items.Insert(i, List2[3]);
      ListBox4.Items.Insert(i, List2[4]);
    end;
finally
  List2.Free;
end;

AlexII 1. Apr 2010 21:26

Re: Meine Drag'n'Drop-Funktion ergänzen
 
Und wieso soll ich überprüfen, ob mehr als 4 Elemente vorhanden sind? :gruebel:

DeddyH 1. Apr 2010 21:29

Re: Meine Drag'n'Drop-Funktion ergänzen
 
Weil Du anschließend auf das 5. Element zugreifst. Und wenn das nicht da ist, gibt es den von Dir beschriebenen Fehler.

AlexII 1. Apr 2010 21:40

Re: Meine Drag'n'Drop-Funktion ergänzen
 
Zitat:

Zitat von DeddyH
Weil Du anschließend auf das 5. Element zugreifst. Und wenn das nicht da ist, gibt es den von Dir beschriebenen Fehler.

Ne es läuft alles. Irgendwie kopiere ich trotzdem das nicht... :roteyes:

DeddyH 1. Apr 2010 21:49

Re: Meine Drag'n'Drop-Funktion ergänzen
 
*Gnarf* Probier das Folgende mal aus, dann weißt Du, was ich meine:
Delphi-Quellcode:
Liste := TStringlist.Create;
try
  Liste.Add('Hallo');
  ShowMessage(Liste[1]); //es ist nur ein Element mit Index 0 (!!) vorhanden
finally
  Liste.Free;
end;

AlexII 1. Apr 2010 21:55

Re: Meine Drag'n'Drop-Funktion ergänzen
 
:gruebel:


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:41 Uhr.
Seite 4 von 6   « Erste     234 56      

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