Autor Beitrag
HBriele
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 80



BeitragVerfasst: Mo 31.01.05 21:37 
:?:
Hi,

kann mir jemand hier bei dem Gegenstück helfen?

Hier wird ein Stringgrid in eine CSV Datei gespeichert. Am Anfang der Datei steht die Anzahl der Zellen und Spalten. Da ich mich nicht mit TstringList auskenne, brauche ich Hilfe.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
 F := TStringList.Create;
  try
    F.Add(IntToStr(StringGrid1.RowCount));
    F.Add(IntToStr(StringGrid1.ColCount));
    for i := 0 to (StringGrid1.RowCount - 1) do
      F.Add(StringGrid1.Rows[i].CommaText);
    F.SaveToFile(datei);
 finally
    F.Free;


Gruß
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 31.01.05 21:47 
Über LoadFromFile kannst Du die Datei wieder einlesen

Unter Items[0] steht dein Rowcount, unter Items[1] deine Spaltenanzahl. Diese beiden Werte weist Du zuerst an deine StringGrid zu.

Danach musst Du nur noch Items[2+i] in einer For-Schleife an Rows[i].CommaText der jeweiligen StringGrid.Row zuweisen.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
HBriele Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 80



BeitragVerfasst: Mo 31.01.05 21:59 
BenBE hat folgendes geschrieben:
Unter Items[0] steht dein Rowcount, unter Items[1] deine Spaltenanzahl. Diese beiden Werte weist Du zuerst an deine StringGrid zu.

Danach musst Du nur noch Items[2+i] in einer For-Schleife an Rows[i].CommaText der jeweiligen StringGrid.Row zuweisen.


Und wie übergebe ich nach dem Einlesen aus TStringList?

Moderiert von user profile iconraziel: Quote-Tag repariert
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 31.01.05 22:06 
Z.B. so hier:
ausblenden Delphi-Quelltext
1:
StringGrid1.Rows[i].CommaText := SL.Items[2+i];					

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
HBriele Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 80



BeitragVerfasst: Mo 31.01.05 22:28 
Irgend wie komme ich da nicht weiter!

Kannst Du näher darauf eingehen, eventuell mit estwas Code?
HBriele Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 80



BeitragVerfasst: Mo 31.01.05 22:50 
Also ich bin Total festgefahren!

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
F : TStringlist;

Begin

  F := TStringList.Create;
   F.LoadFromFile(datei);
 dann muß doch Zeile 0 RowCount übergeben werden!

    StringGrid1.RowCount := F.????


Anschließend die Schleife ? oder ?

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt
HBriele Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 80



BeitragVerfasst: Di 01.02.05 00:25 
Danke,
hab es geschafft .