1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69:
| interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, StdCtrls, Menus, ExtCtrls;
type TForm1 = class(TForm) StringGrid1: TStringGrid; MainMenu1: TMainMenu; Datei1: TMenuItem; NeuerEintrag1: TMenuItem; Eintragbearbeiten1: TMenuItem; Eintraglschen1: TMenuItem; N1: TMenuItem; Beenden1: TMenuItem; Beendenohnezuspeichern1: TMenuItem; Image1: TImage; ComboBox1: TComboBox; procedure NeuerEintrag1Click(Sender: TObject); procedure Beenden1Click(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end;
var Form1: TForm1; implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.NeuerEintrag1Click(Sender: TObject); begin form2.show; end;
procedure TForm1.Beenden1Click(Sender: TObject); begin gridspeichern(StringGrid1,'c:\test.grd'); form1.Close;
end; procedure gridspeichern(grd:TStringGrid;Datei:string); var sl:TStringlist; x,y:integer; begin sl:=TStringlist.create; sl.add(inttostr(grd.colcount)); sl.add(inttostr(grd.rowcount)); for x:=0 to grd.ColCount-1 do for y:=0 to grd.RowCount-1 do sl.add(grd.cells[x,y]); for x:=0 to grd.ColCount-1 do sl.add(inttostr(grd.ColWidths[x])); for x:=0 to grd.RowCount-1 do sl.add(inttostr(grd.RowHeights[x])); sl.add(inttostr(grd.clientwidth)); sl.add(inttostr(grd.clientheight)); sl.add(inttostr(ord(grd.ScrollBars))); sl.savetofile(datei); sl.free; end;
end. |