DBGrid включаем в режим multiSelect. На примере сбора поля ID из базы данных
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
procedure TVisualFrame_HTTP.StatusBarClick(Sender: TObject); var idList: TStringList; i: integer; s: string; begin idList := TStringList.Create; try if DBGrid.SelectedRows.Count > 0 then with DBGrid.DataSource.DataSet do for i := 0 to DBGrid.SelectedRows.Count-1 do begin GotoBookmark(pointer(DBGrid.SelectedRows.Items[i])); idList.Add(FieldByName('id').AsInteger.ToString()); end; for i := 0 to idList.Count-1 do s := s + IDList[i] + #13#10; ShowMessage(s); finally IDList.Free; end; end; |