![]() |
TStrings Liste
moin moin
ich brauch mal eure hilfe mit TStrings also ich habe ein Grid "Grid" und eine String liste "aList : TStrings;" hmm wie bekomme ich die daten aus der liste nun in das Grid rein ? gut eine schleife durchlaufen
Delphi-Quellcode:
das ist nicht das problem aber wie bekomme ich die daten aus den TStrings raus?inc(nBild); Grid.RowCount := Grid.RowCount+1; Grid.Cells[0,nBild] := 'test1';
Delphi-Quellcode:
for n := 0 to aList.Count do begin
inc(nBild); Grid.RowCount := Grid.RowCount+1; Grid.Cells[0,nBild] := 'test1'; Grid.Cells[1,nBild] := aList[nBild]; Grid.Cells[2,nBild] := 'test3'; end; |
Re: TStrings Liste
alist[index]
Mfg |
Re: TStrings Liste
Was steht genau in der Liste? Zeilen/Spalten?
|
Re: TStrings Liste
keine spalten
eigentlich nur Pfad angaben
Delphi-Quellcode:
so sieht zur zeit mein programm aus
unit Main;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids; type TForm1 = class(TForm) Grid: TStringGrid; Button1: TButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private-Deklarationen } public nBild : integer; end; procedure FileList(const APath, AExt: string; ARecurse: Boolean; AList: TStrings); var Form1: TForm1; implementation {$R *.dfm} //****************************************************************************** procedure TForm1.Button1Click(Sender: TObject); var cPfad : string; aList : TStrings; n : integer; begin cPfad := 'c:/test/'; FileList(cPfad, '*.jpg', True, aList); for n := 0 to aList.Count do begin inc(nBild); Grid.RowCount := Grid.RowCount+1; Grid.Cells[0,nBild] := 'test1'; Grid.Cells[1,nBild] := aList[nBild]; Grid.Cells[2,nBild] := 'test3'; end; end; //****************************************************************************** procedure FileList(const APath, AExt: string; ARecurse: Boolean; AList: TStrings); var F : TSearchRec; Path : string; begin Path := IncludeTrailingPathDelimiter(APath); // nur für Delphi 4 und höher! if (ARecurse) and (FindFirst(Path + '*.*', faAnyFile, F) = 0) then try repeat if (F.Name <> '.') and (F.Name <> '..') and ((F.Attr and faDirectory) = faDirectory) then FileList(Path + F.Name, AExt, ARecurse, AList); until FindNext(F) <> 0; finally FindClose(F); end; if FindFirst(Path + AExt, faAnyFile, F) = 0 then try repeat if (F.Name <> '.') and (F.Name <> '..') and ((F.Attr and faDirectory) <> faDirectory) then AList.Add(Path + F.Name); until FindNext(F) <> 0; finally FindClose(F); end; end; //****************************************************************************** procedure TForm1.FormCreate(Sender: TObject); begin nBild := 0; Grid.Cells[0,0]:= 'Bildname'; Grid.Cells[1,0]:= 'Pfad'; Grid.Cells[2,0]:= 'Erstellungdatum'; end; end. |
Re: TStrings Liste
Zitat:
|
Re: TStrings Liste
Also alles in einer Zeile?
Delphi-Quellcode:
Grid.Rows[0].Assign( Alist);
|
Re: TStrings Liste
Hmm hab noch ein Fehler drin
Delphi-Quellcode:
die meldung
procedure TForm1.Button1Click(Sender: TObject);
var cPfad : string; aListe : TStrings; n : integer; begin cPfad := 'c:/test/'; FileList(cPfad, '*.jpg', True, aListe); for n := 0 to aListe.Count do begin inc(nBild); Grid.RowCount := Grid.RowCount+1; Grid.Cells[0,nBild] := 'test1'; Grid.Rows[1].Assign(aListe); Grid.Cells[2,nBild] := 'test3'; end; end; Zitat:
aListe : TStrings; oder irre ich mich ? |
Re: TStrings Liste
da fehlt noch ein
Delphi-Quellcode:
Mfg
aliste:=TStringList.Create;
|
Re: TStrings Liste
Wie sieht FileList() aus?
Delphi-Quellcode:
erzeugt nur einen Referenzvariable aber kein Objekt.
aListe : TStrings;
Delphi-Quellcode:
Warum die Schleife?
aListe := TStringList.Create;
|
Re: TStrings Liste
Zitat:
Mfg |
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:44 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