Hallo nochmal,
da ich ja nichts zu tun hab

, hier mal ein Grid das fünf Zeilen und umfasst und per Button auf die nächsten Seiten des Grids schaltet.
Das macht sich sehr gut bei Grids die mehr als 20 Datensätze haben. Da ich ja warscheinlich kein Javascript im Browser angeschaltet haben darf, musste ich das "per Hand" konstruieren und konnte nicht die guten TMS oder Standard Komponenten nehmen. Das Grid hat eine editierbare spalte, aber diesmal keine Buttons in der dritten Spalte. die Datenbank wird über einen extra Button aktualisiert :
Code:
procedure TIWForm1.gridaufbauen1();
var i: integer;
begin
IWGrid321.ColumnCount:=2;
IWGrid321.Width:=240;
IWGrid321.cell[0,0].Width:='150';
IWGrid321.cell[0,1].width:='90';
IWGrid321.cell[0,0].text := 'Name';
IWGrid321.cell[0,1].text := 'Geburtstag';
IWGrid321.Font.Style:=[];
table1.Open;
table1.First;
iwgrid321.RowCount:=6;
for i := 1 to iwgrid321.RowCount-1 do begin
iwgrid321.cell[i,0].text := table1.fieldbyname('Name').asstring;
with iwgrid321.Cell[i,1] do begin //editfeld
Control:=TIWEdit32.Create(self);
with TIWEdit32(Control) do begin
Text:=table1.fieldbyname('Geburtstag').asstring;
width:=90;
end;
end;
table1.Next;
end;
//zweites unteres Grid mit den Buttons aufbauen
IWGrid322.RowCount:=1;
if 5 mod (trunc(table1.RecordCount / 5)) = 0 then begin
IWGrid322.ColumnCount:= trunc(table1.RecordCount / 5);
IWGrid322.Width:= trunc(IWGrid322.ColumnCount * 20);
end
else begin
IWGrid322.ColumnCount:= trunc(table1.RecordCount / 5)+1;
IWGrid322.Width:= trunc((IWGrid322.ColumnCount) * 20);
end;
for i:=0 to IWGrid322.ColumnCount-1 do begin
with IWGrid322.Cell[0,i] do begin
Control:=TIWButton32.Create(self);
with TIWButton32(Control) do begin
Text:=inttostr(i+1);
name:='gri'+inttostr(i+1);
onclick:=seitenclick;
end;
end;
end;
table1.Close;
end;
procedure TIWForm1.seitenclick(ASender: TObject);
var
zeilenbutton: string;
i :integer;
begin
zeilenbutton:= (ASender as TIWButton32).name;
zeilenbutton:= copy(zeilenbutton,4,length(zeilenbutton));
table1.Open;
table1.RecNo:= trunc((strtoint(zeilenbutton) * 5)-5);
if zeilenbutton = '1' then
table1.First;
for i := 1 to iwgrid321.RowCount-1 do begin
if table1.Eof then begin //wenn das ende der datenbanktabelle errreicht ist, soll nichts mehr im grid angezeigt werden
iwgrid321.cell[i,0].text := '';
with iwgrid321.Cell[i,1].Control do begin //editfeld
Text:='';
end;
end
else begin
iwgrid321.cell[i,0].text := table1.fieldbyname('Name').asstring;
with iwgrid321.Cell[i,1].Control do begin //editfeld
Text:=table1.fieldbyname('Geburtstag').asstring;
end;
end;
table1.Next;
end;
table1.Close;
end;