unit UnStringGrid;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, StrUtils, Printers, ClipBrd, Grids;
type
TForm1 =
class(TForm)
Label1: TLabel;
OpenDialog1: TOpenDialog;
PrinterSetupDialog1: TPrinterSetupDialog;
MainMenu1: TMainMenu;
datei: TMenuItem;
drucken: TMenuItem;
ffnen1: TMenuItem;
Druckereinstellungen1: TMenuItem;
Drucken1: TMenuItem;
PrintDialog1: TPrintDialog;
AlleFelderlschen1: TMenuItem;
StringGrid1: TStringGrid;
Beenden1: TMenuItem;
procedure ffnen1Click(Sender: TObject);
procedure Druckereinstellungen1Click(Sender: TObject);
procedure Drucken1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Beenden1Click(Sender: TObject);
//Hier
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
// und hier so wie du gesagt hast.
implementation
{$R *.dfm}
procedure FillGrid(sg: TStringGrid; lines: TStrings; delim: Char);
var
i: Integer;
begin
for i := 0
to Pred(lines.Count)
do
Explode(lines[i], delim, sg.Rows[sg.FixedRows + i]);
end;
procedure TForm1.ffnen1Click(Sender: TObject);
var
sl: TStringList;
begin
if OpenDialog1.Execute
then
begin
sl := TStringList.Create;
try
sl.LoadFromFile(OpenDialog1.FileName);
FillGrid(StringGrid1, sl, '
;');
finally
sl.Free;
end;
end;
end;