Forum > Databases

DBGrid multiselect

(1/2) > >>

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.


You could use Bookmarklist's enumerator, something like:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---        for book in theDbGrid.SelectedRows.GetEnumerator([]) do begin          <do something with the current record>        end; 
GetEnumerator takes a set of options:

* breDisableDataset. Which disables any db gui control, so iterating over selected records is faster
* breStopOnInvalidBookmark. Which stops iteration if a bookmark is invalid
* breRestoreCurrent. Which restores the current record after iterating selected records has finished

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?


Ah, solved. A post from 2017 by GAN showed me how to use the bookmark, and relate it to the dataset.

Thanks all

Could you please post the link, so this thread is linked to the solution ?


[0] Message Index

[#] Next page

Go to full version