DBGrid multiselect lazarus / 16-Databases ---------------------------------------------------------------------- teresa · 2024-05-18 09:24 I have a DBGrid, with multi-select enabled. I need to know which rows are selected, and short of checking the entire grid row  by row have come up short. With more than 2000 rows, that is time consuming Is there a more direct way? I see there is the bookmark list, but haven't had any success with it. Thanks Teresa ---------------------------------------------------------------------- jesusr · 2024-05-18 18:12 You could use Bookmarklist's enumerator, something like: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         for book in theDbGrid.SelectedRows.GetEnumerator([]) do begin                  end;  GetEnumerator takes a set of options: breDisableDataset. Which disables any db gui control, so iterating over selected records is fasterbreStopOnInvalidBookmark. Which stops iteration if a bookmark is invalidbreRestoreCurrent. Which restores the current record after iterating selected records has finished ---------------------------------------------------------------------- teresa · 2024-05-19 02:36 Thanks Jesusr. I've had no success so far interpreting the byte array (15 bytes) returned for each bookmark. Is there any documentation on that? T. ---------------------------------------------------------------------- teresa · 2024-05-19 05:02 Ah, solved. A post from 2017 by GAN showed me how to use the bookmark, and relate it to the dataset. Thanks all T. ---------------------------------------------------------------------- CharlyTango · 2024-05-19 08:54 Could you please post the link, so this thread is linked to the solution ? ---------------------------------------------------------------------- TRon · 2024-05-19 11:09 Quote from: CharlyTango on May 19, 2024, 10:54:33 amCould you please post the link, so this thread is linked to the solution ? The only related post from GAN that I was able to locate can be found in this thread ---------------------------------------------------------------------- teresa · 2024-05-19 22:01 Quote from: CharlyTango on May 19, 2024, 10:54:33 amCould you please post the link, so this thread is linked to the solution ? Sure: https://forum.lazarus.freepascal.org/index.php/topic,36900.msg246513.h tml#msg246513 ---------------------------------------------------------------------- egsuh · 2024-05-22 03:32 I'm trying to extend this to delete multiple rows at once in following way. BeforeDelete event is to delete the record from SQL server before the record is deleted at the TDataSet. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TSampleList.DBNavigator1Click(Sender: TObject;   Button: TDBNavButtonType);var   i: Integer;begin   if Button = nbDelete then begin      for i:=0 to dbgSampleList.SelectedRows.Count-1 do         with dbgSampleList.DataSource.DataSet do         begin            GotoBookmark(pointer(dbgSampleList.SelectedRows.Items[i]));          Delete;         end;   end;end; procedure TSampleList.bdsSampleListBeforeDelete(DataSet: TDataSet);var   tclause: string;begin   TClause := Format('project_id=''%s'' and respondent_id=%d',             [pid, bdsSampleList.FieldByName('RID').AsInteger]);   if not DataAccess.DeleteARecord('SampleList', tclause)      then bdsSampleList.Cancel;end;  This deletes as I want, but it causes memory leak, as attached in the image. What might have caused this?