![]() |
StringGrid aus Form2 in Form1 abspeichern
Hallo,
möchte gerne, wenn das Hauptformular(Form1) beendet wird, dass das StringGrid von Form2 abgespeichert wird.
Delphi-Quellcode:
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin DeleteFile(ExtractFilePath(ParamStr(0)) + 'Ereignisprotokoll.dat'); SaveStringGrid(Form2.StringGrid1, ExtractFilePath(ParamStr(0)) + 'Ereignisprotokoll.dat'); end; |
AW: StringGrid aus Form2 in Form1 abspeichern
Und? Funktioniert es so nicht? Fehler?
|
AW: StringGrid aus Form2 in Form1 abspeichern
Hallo,
ColCount und RowCount setzen und dann
Delphi-Quellcode:
for i := 0 to StringGrid1.RowCount - 1 do
StringGrid2.Rows[i].Assign(StringGrid1.Rows[i]); |
AW: StringGrid aus Form2 in Form1 abspeichern
Zitat:
|
AW: StringGrid aus Form2 in Form1 abspeichern
Was ist SaveStringGrid und wo liegt das?
|
AW: StringGrid aus Form2 in Form1 abspeichern
Und wo steht SaveStringGrid? Vermutlich lediglich im implementation-Abschnitt einer der Units.
|
AW: StringGrid aus Form2 in Form1 abspeichern
Zitat:
Zitat:
|
AW: StringGrid aus Form2 in Form1 abspeichern
Wenn die MainForm geschlossen wird, dann beendet sich eh alles,
also warum speichert Form2 sich nicht selber? (OnDestroy) |
AW: StringGrid aus Form2 in Form1 abspeichern
![]() Zitat:
Nur ich verstehe nicht wo das Problem ist diese Prozedur zu verwenden. |
AW: StringGrid aus Form2 in Form1 abspeichern
Hallo,
ah, < Unit1 und Unit2 kennen sich! > Und woher kennt Unit2 SaveStringGrid. In welcher Unit ist das deklariert? Mal so in der Schnelle:
Delphi-Quellcode:
unit LoadSaveStringGrid; interface uses System, Grids; // ??? procedure SaveStringGrid(StringGrid: TStringGrid; const FileName: TFileName); procedure LoadStringGrid(StringGrid: TStringGrid; const FileName: TFileName); implementation procedure SaveStringGrid(StringGrid: TStringGrid; const FileName: TFileName); var f: TextFile; i, k: Integer; begin AssignFile(f, FileName); Rewrite(f); with StringGrid do begin // Write number of Columns/Rows Writeln(f, ColCount); Writeln(f, RowCount); // loop through cells for i := 0 to ColCount - 1 do for k := 0 to RowCount - 1 do Writeln(F, Cells[i, k]); end; CloseFile(F); end; // Load a TStringGrid from a file procedure LoadStringGrid(StringGrid: TStringGrid; const FileName: TFileName); var f: TextFile; iTmp, i, k: Integer; strTemp: String; begin AssignFile(f, FileName); Reset(f); with StringGrid do begin // Get number of columns Readln(f, iTmp); ColCount := iTmp; // Get number of rows Readln(f, iTmp); RowCount := iTmp; // loop through cells & fill in values for i := 0 to ColCount - 1 do for k := 0 to RowCount - 1 do begin Readln(f, strTemp); Cells[i, k] := strTemp; end; end; CloseFile(f); end; end. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:41 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