AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

TStrings Liste

Ein Thema von tmrxxoja · begonnen am 16. Mär 2008 · letzter Beitrag vom 16. Mär 2008
Antwort Antwort
Seite 1 von 2  1 2      
tmrxxoja

Registriert seit: 16. Mär 2008
Ort: Helgoland
27 Beiträge
 
Delphi 7 Professional
 
#1

TStrings Liste

  Alt 16. Mär 2008, 12:54
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:
  
  inc(nBild);
  Grid.RowCount := Grid.RowCount+1;
  Grid.Cells[0,nBild] := 'test1';
das ist nicht das problem aber wie bekomme ich die daten aus den TStrings raus?


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;
  Mit Zitat antworten Zitat
Benutzerbild von Fussball-Robby
Fussball-Robby

Registriert seit: 22. Okt 2007
Ort: Nähe Köln
1.063 Beiträge
 
Delphi 7 Enterprise
 
#2

Re: TStrings Liste

  Alt 16. Mär 2008, 12:59
alist[index]

Mfg
Robert L.
Der folgende Satz ist richtig!
Der vorherige Satz ist falsch!

Paradox
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#3

Re: TStrings Liste

  Alt 16. Mär 2008, 12:59
Was steht genau in der Liste? Zeilen/Spalten?
Markus Kinzler
  Mit Zitat antworten Zitat
tmrxxoja

Registriert seit: 16. Mär 2008
Ort: Helgoland
27 Beiträge
 
Delphi 7 Professional
 
#4

Re: TStrings Liste

  Alt 16. Mär 2008, 13:04
keine spalten

eigentlich nur Pfad angaben

Delphi-Quellcode:
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.
so sieht zur zeit mein programm aus
  Mit Zitat antworten Zitat
Benutzerbild von Fussball-Robby
Fussball-Robby

Registriert seit: 22. Okt 2007
Ort: Nähe Köln
1.063 Beiträge
 
Delphi 7 Enterprise
 
#5

Re: TStrings Liste

  Alt 16. Mär 2008, 13:05
Zitat von Fussball-Robby:
alist[index]
Robert L.
Der folgende Satz ist richtig!
Der vorherige Satz ist falsch!

Paradox
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#6

Re: TStrings Liste

  Alt 16. Mär 2008, 13:06
Also alles in einer Zeile?

Grid.Rows[0].Assign( Alist);
Markus Kinzler
  Mit Zitat antworten Zitat
tmrxxoja

Registriert seit: 16. Mär 2008
Ort: Helgoland
27 Beiträge
 
Delphi 7 Professional
 
#7

Re: TStrings Liste

  Alt 16. Mär 2008, 13:20
Hmm hab noch ein Fehler drin

Delphi-Quellcode:
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;
die meldung

Zitat:
Variable "aListe" ist möglicherweise nicht initialisiert worden
hmm aber ist sie doch oder ??

aListe : TStrings;

oder irre ich mich ?
  Mit Zitat antworten Zitat
Benutzerbild von Fussball-Robby
Fussball-Robby

Registriert seit: 22. Okt 2007
Ort: Nähe Köln
1.063 Beiträge
 
Delphi 7 Enterprise
 
#8

Re: TStrings Liste

  Alt 16. Mär 2008, 13:22
da fehlt noch einaliste:=TStringList.Create; Mfg
Robert L.
Der folgende Satz ist richtig!
Der vorherige Satz ist falsch!

Paradox
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#9

Re: TStrings Liste

  Alt 16. Mär 2008, 13:23
Wie sieht FileList() aus?
aListe : TStrings; erzeugt nur einen Referenzvariable aber kein Objekt.

aListe := TStringList.Create; Warum die Schleife?
Markus Kinzler
  Mit Zitat antworten Zitat
Benutzerbild von Fussball-Robby
Fussball-Robby

Registriert seit: 22. Okt 2007
Ort: Nähe Köln
1.063 Beiträge
 
Delphi 7 Enterprise
 
#10

Re: TStrings Liste

  Alt 16. Mär 2008, 13:25
Zitat von mkinzler:
Wie sieht FileList() aus?
Hat er oben schon gepostet

Mfg
Robert L.
Der folgende Satz ist richtig!
Der vorherige Satz ist falsch!

Paradox
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:29 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz