![]() |
Listbox Leeren
sry wenn ich so mit der Tür ins Haus falle aber ich hab ein Problem :roll:
Also ich hab 2 ListBoxen
Delphi-Quellcode:
und über
...
type TForm1 = class(TForm) LBxCopy0001: TListBox; LBxCopy0002: TListBox;
Delphi-Quellcode:
füge ich Dateien ein
...
LBxCopy0001.Items.Add(gFile0001[inte0001]); LBxCopy0002.Items.Add(GetFileVersion(gfile0001[inte0001])) Wenn ich diese Dateien mit
Delphi-Quellcode:
entferne und neue Dateien einfüge werden die Alten wieder eingefügt.
LBxCopy0001.Items.clear;
LBxCopy0002.Items.clear; (Das soll nicht Passieren !:shock: ) Kann mir jemand helfen??? |
Re: Listbox Leeren
Also sofern du nicht selbst irgendwie die alten Daten einfügst, sollten die dort nicht mehr auftauchen. Am besten du postest mal etwas mehr Code, damit man nach dem Fehler suchen kann.
|
Re: Listbox Leeren
Ich schätze, es liegt an Deinem Feld "gFile0001[]"
Wie fügst Du denn in dieses eine Neue Datei ein?! .. ich schätze, dass selbst nach dem Einfügen, an der Stelle inte0001 immernoch die alte Datei ist. Oder Du hast einfach vergessen, inte0001 zu incrementieren... Poste mal den Code, wo Du das neue File einfügst. |
Re: Listbox Leeren
Wenns nicht an der listbox liegt hängts entweder an meinem FindAllFiles
Delphi-Quellcode:
das ich durch
function FindAllFiles(RootFolder: string; Mask: string = '*.*'; Recurse: Boolean
= True): TStinDynA; var //--Funktionsvariablen--------------------------------------------------------------------- Wn32FiDa: TWin32FindData; File0001: THandle; begin if AnsiLastChar(RootFolder) <> '\' then begin RootFolder := RootFolder + '\'; end; if Recurse then begin{if-1} File0001 := FindFirstFile(PChar(RootFolder + '*.*'), Wn32FiDa); if File0001 <> INVALID_HANDLE_VALUE then try {try(if-2)} repeat if Wn32FiDa.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY=FILE_ATTRIBUTE_DIRECTORY then begin if (string(Wn32FiDa.cFileName) <> '.') and (string(Wn32FiDa.cFileName) <> '..')then begin FindAllFiles(RootFolder + Wn32FiDa.cFileName, Mask, Recurse); end; end; until FindNextFile(File0001, Wn32FiDa) = False; finally windows.FindClose(File0001); end;{try(if-2)} end;{if 1} File0001 := FindFirstFile(PChar(RootFolder + '*.*'), Wn32FiDa); if File0001 <> INVALID_HANDLE_VALUE then try {try(if-4)} repeat if Wn32FiDa.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY <> FILE_ATTRIBUTE_DIRECTORY then begin gFileCont := length(gFile0001)+1; Setlength(gFile0001, gFileCont); gFile0001[gFileCont - 1] := RootFolder + String(Wn32FiDa.cFileName); end;{if-3} until FindNextFile(File0001, Wn32FiDa) = False; finally Windows.FindClose(File0001); end;{try(if-4)} end;{Funktion}
Delphi-Quellcode:
aufrufe.
FindAllFiles(EdtCopy0001.Text, '*.*', true);
oder am Phathdialog den ich benutze um Dateien zu suchen |
Re: Listbox Leeren
Delphi-Quellcode:
so rufe ich Pathdialog auf
if PathDialog1.Execute(Filesuch) =false then
begin Exit; end{if} else begin EdtCopy0001.Text:=PathDialog1.LastPath; FindAllFiles(EdtCopy0001.Text, '*.*', true); for inte0001 := 0 to length(gFile0001) - 1 do begin LBxCopy0001.Items.Add(gFile0001[inte0001]); LBxCopy0002.Items.Add(GetFileVersion(gfile0001[inte0001])) end;{for-schleife} end;{else} |
Re: Listbox Leeren
Und wo rufst du dein Clear auf?
MfG freak :gruebel: |
Re: Listbox Leeren
Delphi-Quellcode:
Hier!
procedure TForm1.Btncopy0004Click(Sender: TObject);
begin LbxCopy0001.Items.clear; LBxCopy0002.Items.clear; EdtCopy0001.Text:=''; end; |
Re: Listbox Leeren
Solltest du die vorhandenen Einträge aus deinem Array vielleicht einfach mal löschen? ;)
Also am Anfang der FindAllFiles z.B. SetLength(gFile0001, 0); o.ä. air |
Re: Listbox Leeren
Es Lebt!!!!!!!!! ähhh Es geht!! :pale:
danke alle miteinander!! ihr wart mir eine große hilfe! :thumb: |
Re: Listbox Leeren
jetzt werden plötzlich nicht mehr alle dateien angezeigt kann mir dabei jemand helfen ?
ist mir erst eben aufgefallen :pale: :oops: |
Re: Listbox Leeren
dann beschreib uns mal, was du geändert hast, damit sich die listboxen leeren lassen. am besten mit code.
|
Re: Listbox Leeren
[i]vorher
Delphi-Quellcode:
Nachher
function FindAllFiles(RootFolder: string; Mask: string = '*.*'; Recurse: Boolean
= True): TStinDynA; var //--Funktionsvariablen--------------------------------------------------------------------- Wn32FiDa: TWin32FindData; File0001: THandle; begin if AnsiLastChar(RootFolder) <> '\' then begin RootFolder := RootFolder + '\'; end; if Recurse then begin{if-1} File0001 := FindFirstFile(PChar(RootFolder + '*.*'), Wn32FiDa); if File0001 <> INVALID_HANDLE_VALUE then try {try(if-2)} repeat if Wn32FiDa.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY=FILE_ATTRIBUTE_DIRECTORY then begin if (string(Wn32FiDa.cFileName) <> '.') and (string(Wn32FiDa.cFileName) <> '..')then begin FindAllFiles(RootFolder + Wn32FiDa.cFileName, Mask, Recurse); end; end; until FindNextFile(File0001, Wn32FiDa) = False; finally windows.FindClose(File0001); end;{try(if-2)} end;{if 1} File0001 := FindFirstFile(PChar(RootFolder + '*.*'), Wn32FiDa); if File0001 <> INVALID_HANDLE_VALUE then try {try(if-4)} repeat if Wn32FiDa.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY <> FILE_ATTRIBUTE_DIRECTORY then begin gFileCont := length(gFile0001)+1; Setlength(gFile0001, gFileCont); gFile0001[gFileCont - 1] := RootFolder + String(Wn32FiDa.cFileName); end;{if-3} until FindNextFile(File0001, Wn32FiDa) = False; finally Windows.FindClose(File0001); end;{try(if-4)} end;{Funktion}
Delphi-Quellcode:
function FindAllFiles(RootFolder: string; Mask: string = '*.*'; Recurse: Boolean
= True): TStinDynA; var //--Funktionsvariablen--------------------------------------------------------------------- Wn32FiDa: TWin32FindData; File0001: THandle; begin SetLength(gFile0001, 0); //<= das hab ich eingefügt!! if AnsiLastChar(RootFolder) <> '\' then begin RootFolder := RootFolder + '\'; end; if Recurse then begin{if-1} File0001 := FindFirstFile(PChar(RootFolder + '*.*'), Wn32FiDa); if File0001 <> INVALID_HANDLE_VALUE then try {try(if-2)} repeat if Wn32FiDa.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY=FILE_ATTRIBUTE_DIRECTORY then begin if (string(Wn32FiDa.cFileName) <> '.') and (string(Wn32FiDa.cFileName) <> '..')then begin FindAllFiles(RootFolder + Wn32FiDa.cFileName, Mask, Recurse); end; end; until FindNextFile(File0001, Wn32FiDa) = False; finally windows.FindClose(File0001); end;{try(if-2)} end;{if 1} File0001 := FindFirstFile(PChar(RootFolder + '*.*'), Wn32FiDa); if File0001 <> INVALID_HANDLE_VALUE then try {try(if-4)} repeat if Wn32FiDa.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY <> FILE_ATTRIBUTE_DIRECTORY then begin gFileCont := length(gFile0001)+1; Setlength(gFile0001, gFileCont); gFile0001[gFileCont - 1] := RootFolder + String(Wn32FiDa.cFileName); end;{if-3} until FindNextFile(File0001, Wn32FiDa) = False; finally Windows.FindClose(File0001); end;{try(if-4)} end;{Funktion} |
Re: Listbox Leeren
:oops: ich bin so blöd!! :wall: :wall:
Ich habs falsch eingefügt. jetzt get's habs jetzt
Delphi-Quellcode:
und auf anhieb klapt's ohne Probleme
procedure TForm1.Btncopy0004Click(Sender: TObject);
begin SetLength(gFile0001, 0); //<= Hier ausprobiert!! LbxCopy0001.Items.clear; LBxCopy0002.Items.clear; EdtCopy0001.Text:=''; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:20 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