首先选中DataGrid的【Options】的【egoMultiSelect】选项,然后代码如下:
var
i, j: Integer;
s: string;
begin
if DataGrid1.SelectedCount > 0 then
with DataGrid1.DataSource.DataSet do
for i := 0 to DataGrid1.SelectedCount - 1 do
begin
Bookmark := DataGrid1.SelectedRows;
for j := 0 to FieldCount - 1 do
begin
if (j > 0) then s := s + ', ';
s := s + Fields[j].AsString;
end;
Memo1.Lines.Add(s);
s := '';
end;
end;