unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Grids, ComCtrls;
type
TForm1 =
class(TForm)
pageControl: TPageControl;
PosText: TTabSheet;
Grid: TTabSheet;
TabSheet2: TTabSheet;
Search: TTabSheet;
Edit: TEdit;
Edit1: TEdit;
StringGrid: TStringGrid;
Panel: TPanel;
Edit2: TEdit;
Button1: TButton;
OpenDialog: TOpenDialog;
SaveDialog: TSaveDialog;
Load: TButton;
Save: TButton;
StringGrid2: TStringGrid;
Edit3: TEdit;
Suchengrid2: TButton;
CopyToGrid2: TButton;
Clear: TButton;
Trennzeichen: TEdit;
procedure Button1Click(Sender: TObject);
procedure LoadClick(Sender: TObject);
procedure Suchengrid2Click(Sender: TObject);
procedure CopyToGrid2Click(Sender: TObject);
procedure ClearClick(Sender: TObject);
procedure EditChange(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure pageControlChange(Sender: TObject);
private
mylist:TStringList;
x,y:
string;
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
j: Integer;
i: Integer;
begin
for j:=0
to stringgrid.colCount-1
do
begin
for i:=0
to StringGrid.rowCount-1
do
begin
if pos(lowercase(edit2.text),lowercase(stringgrid.Cells[j,i]))>0
then
begin
StringGrid.Row := i;
StringGrid.Col := j;
ShowMessage(edit2.Text+'
wurde in Zeile '+intToStr(i)+ '
in Spalte ' + inttostr(j)+'
gefunden');
end;
end;
end;
end;
procedure TForm1.LoadClick(Sender: TObject);
var
i,count:Integer;
delimiter:char;
mylist:TStringList;
begin
OpenDialog.Execute;
mylist:= TStringList.Create;
mylist.LoadFromFile(OpenDialog.FileName);
for i := 0
to mylist.Count-1
do
mylist.Strings[i] := '
;'+mylist.Strings[i];
for i:=0
to mylist.count-1
do
begin
Stringgrid.Rows[i+1].delimiter := '
;';
StringGrid.Rows[i+1].DelimitedText := mylist[i];
end;
end;
procedure TForm1.Suchengrid2Click(Sender: TObject);
var
i: Integer;
j: Integer;
begin
for j:=0
to stringgrid2.colCount-1
do
begin
for i:=0
to StringGrid2.rowCount-1
do
begin
if pos(lowercase(edit3.text),lowercase(stringgrid2.Cells[j,i]))>0
then
begin
StringGrid2.Row := i;
StringGrid2.Col := j;
ShowMessage(edit3.Text+'
wurde in Zeile '+intToStr(i)+ '
in Spalte ' + inttostr(j)+'
gefunden');
end;
end;
end;
end;
procedure TForm1.CopyToGrid2Click(Sender: TObject);
begin
StringGrid:= StringGrid2;
end;
procedure TForm1.ClearClick(Sender: TObject);
var
mylist: TStringList;
begin
// StringGrid2
end;
procedure TForm1.EditChange(Sender: TObject);
var
tmp:integer;
komma: Boolean;
begin
if length(edit.text)>2
then
begin
x:='
';
y:='
';
tmp:= 0;
komma:= false;
while tmp< Length(edit.Text)
do
begin
if not (copy(edit.Text,tmp+1,1)='
,')
then
if komma
then
y:=y+copy(edit.Text,tmp+1,1)
else
x:=x+copy(edit.Text,tmp+1,1)
else
komma:= true;
inc(tmp);
end;
end;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
if not (x= '
')
or (y= '
')
then
begin
if StringGrid.ColCount< strtoint(x)
then
StringGrid.ColCount := strtoint (x);
if StringGrid.RowCount< strtoint (y)
then
StringGrid.RowCount := strtoint (y);
end;
StringGrid.Cells[strtoint(x),strtoint(y)]:= edit1.Text;
end;
procedure TForm1.pageControlChange(Sender: TObject);