with query1 do begin first; for i:=0 to recordcount-1 do begin if fieldvalue('abc')='xxx' then //进行判断 begin ..... //执行你的操作 end; next; end; end;
谢谢,不过我想你理解错我的意思了,DBGRID是可以复选,我是要取得在DBGRID中被选种的那些记录在数据库里面的相应记录,比如 if dbgrid1.row[i].select then //假设有这样的属性,其实没有:( begin //我的操作 end; query1.next; dbgrid1.next; //假设有这样的属性
for i := 0 to DBGrid.SelectedRows.Count - 1 do begin Query.GotoBook(pointer(DBGrid.SelectedRows.Items[i])); .... end;
这是D5自带帮助: procedure TForm1.Button1Click(Sender: TObject); var i, j: Integer; s: string; begin if DBGrid1.SelectedRows.Count>0 then with DBGrid1.DataSource.DataSet do for i:=0 to DBGrid1.SelectedRows.Count-1 do begin GotoBook(pointer(DBGrid1.SelectedRows.Items[i])); for j := 0 to FieldCount-1 do begin if (j>0) then s:=s+', '; s:=s+Fields[j].AsString; end; Listbox1.Items.Add(s); s:= ''; end; end;
procedure TForm1.Button1Click(Sender: TObject); var i, j: Integer; s: string; begin if DBGrid1.SelectedRows.Count>0 then with DBGrid1.DataSource.DataSet do for i:=0 to DBGrid1.SelectedRows.Count-1 do begin GotoBook(pointer(DBGrid1.SelectedRows.Items[i])); for j := 0 to FieldCount-1 do begin if (j>0) then s:=s+', '; s:=s+Fields[j].AsString; end; Listbox1.Items.Add(s); s:= ''; end; end;
begin
first;
for i:=0 to recordcount-1 do
begin
if fieldvalue('abc')='xxx' then //进行判断
begin
..... //执行你的操作
end;
next;
end;
end;
if dbgrid1.row[i].select then //假设有这样的属性,其实没有:(
begin
//我的操作
end;
query1.next;
dbgrid1.next; //假设有这样的属性
begin
Query.GotoBook(pointer(DBGrid.SelectedRows.Items[i]));
....
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i, j: Integer;
s: string;
begin
if DBGrid1.SelectedRows.Count>0 then
with DBGrid1.DataSource.DataSet do
for i:=0 to DBGrid1.SelectedRows.Count-1 do
begin
GotoBook(pointer(DBGrid1.SelectedRows.Items[i]));
for j := 0 to FieldCount-1 do
begin if (j>0) then s:=s+', ';
s:=s+Fields[j].AsString;
end;
Listbox1.Items.Add(s);
s:= '';
end;
end;
var
i, j: Integer;
s: string;
begin
if DBGrid1.SelectedRows.Count>0 then
with DBGrid1.DataSource.DataSet do
for i:=0 to DBGrid1.SelectedRows.Count-1 do
begin
GotoBook(pointer(DBGrid1.SelectedRows.Items[i]));
for j := 0 to FieldCount-1 do
begin if (j>0) then s:=s+', ';
s:=s+Fields[j].AsString;
end;
Listbox1.Items.Add(s);
s:= '';
end;
end;