先把多選dgMultiSelect設置成True;
procedure TForm1.Button1Click(Sender: TObject);
var
I:integer;
begin
for I := 0 to 3 do
begin
if ADOTable1.Locate('ID',I*2,[]) then
begin
DBGridEh1.SelectedRows.CurrentRowSelected:=true;
end;
end;
ShowMessage(IntToStr(DBGridEh1.SelectedRows.Count)); 這裏顯示爲4個。
end;spa