如果多条记录被选中的话请用: with myDBGrid do begin if SelectedRows.Count>0 then with DataSource.DataSet do for i:=0 to SelectedRows.Count-1 do begin GotoBook(pointer(SelectedRows.Items[i])); myDBGrid.DataSource.DataSet.FieldByName('').As... .... end; end;
是吗? 我以前难道用的都是在编辑状态下的 这个我道是不记得了, 我只记得这个东西对Sql Server 支持得不好!
第一,如果选中1条记录的话,用DBGrid.DataSource.DataSet.RecNo就可以了 第二,如果选中多条记录with myDBGrid do begin if DBGrid.SelectedRows.Count>0 then with DataSource.DataSet do for i:=0 to SelectedRows.Count-1 do begin GotoBook(pointer(SelectedRows.Items[i])); myDBGrid.DataSource.DataSet.FieldByName('').As... .... end; end;
with myDBGrid do
begin
if SelectedRows.Count>0 then
with DataSource.DataSet do
for i:=0 to SelectedRows.Count-1 do
begin
GotoBook(pointer(SelectedRows.Items[i]));
myDBGrid.DataSource.DataSet.FieldByName('').As...
....
end;
end;
我以前难道用的都是在编辑状态下的
这个我道是不记得了,
我只记得这个东西对Sql Server 支持得不好!
第二,如果选中多条记录with myDBGrid do
begin
if DBGrid.SelectedRows.Count>0 then
with DataSource.DataSet do
for i:=0 to SelectedRows.Count-1 do
begin
GotoBook(pointer(SelectedRows.Items[i]));
myDBGrid.DataSource.DataSet.FieldByName('').As...
....
end;
end;
前面的代码delphi帮助文件中是可以找到的