procedure TIWForm2.gridaufbauen();
var i: integer;
begin
iwgrid321.cell[0,0].text := 'Name';
iwgrid321.cell[0,1].text := 'Geburtstag';
iwgrid321.cell[0,2].text := ' ';
table1.Open;
table1.First;
iwgrid321.RowCount:=table1.RecordCount+1;
for i := 1 to table1.RecordCount 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;
end;
end;
with iwgrid321.Cell[i,2] do begin //button
Control:=TIWButton32.Create(self);
with TIWButton32(Control) do begin
Text:='Ändern';
name:='but'+inttostr(i);
onclick:=testprozedur; //
sql-Anweisung
end;
end;
table1.Next;
end;
table1.Close;
end;
//------------------------------------------------------
procedure TIWForm2.testprozedur(ASender: TObject);
var
zeile: integer;
zeilenname: string;
begin
zeilenname:= (ASender as TIWButton32).name;
zeilenname:= copy(zeilenname,4,length(zeilenname));
IWLabel321.Caption:=iwgrid321.Cell[strtoint(zeilenname),1].Control.text;
table1.Open;
table1.RecNo:=strtoint(zeilenname);
table1.Edit;
table1.FieldByName('Geburtstag').AsString:=iwgrid321.Cell[strtoint(zeilennam
e),1].Control.text;
table1.Post;
gridaktualisieren;
end;
//---------------------------------------------------------------
procedure TIWForm2.gridaktualisieren;
var i: integer;
begin
table1.Open;
table1.First;
for i := 1 to table1.RecordCount do begin
with iwgrid321.Cell[i,1] do begin //editfeld
with TIWEdit32(Control) do begin
Text:=table1.fieldbyname('Geburtstag').asstring;
end;
end;
table1.Next;
end;
table1.Close;
end;