[Title change] How to set a checkbox in DBGrid linked to a BookmarkList lazarus / 16-Databases ---------------------------------------------------------------------- daveinhull · 2019-03-14 02:20 Hi, I'm using a BookmarkList to add an additonal column to a DBGrid containing a boolean checkbox with some code I found (see below) snd it works perfect for selecting and deselecting individual rows checkboxes. However, I'd like to add options (buttons) to select and deselect all checkboxes, but just can't figure out how to access the boolean value for the checkboxes. I've tried setting up a loop to move through the data set associated with the other values and usedCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     RecList.CurrentRowSelected := True; but this does not show up in the actual grid. I think I need to access the AState, but just dont know where this is as it doesn't belong to either the grid or the bookmarklist. Any help would be really appreciated, thanks 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 TForm1.DBGrid1CellClick(Column: TColumn);begin  if Column.Index=1 then    RecList.CurrentRowSelected := not RecList.CurrentRowSelected;end; procedure TForm1.FormCreate(Sender: TObject);begin  RecList := TBookmarkList.Create(DbGrid1);end; procedure TForm1.FormDestroy(Sender: TObject);begin  RecList.Free;end; procedure TForm1.DBGrid1UserCheckboxState(sender: TObject; column: TColumn; var AState: TCheckboxState);begin  if RecList.CurrentRowSelected then    AState := cbChecked  else    AState := cbUnchecked;end; ---------------------------------------------------------------------- daveinhull · 2019-03-15 05:49 Hi, anyone got any thoughts on this? Dave ---------------------------------------------------------------------- jesusr · 2019-03-16 01:06 It works here: 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 TForm1.ToggleAll(Ok:boolean);var  book: TBookMark;begin  FTable.DisableControls;  book := FTable.GetBookmark;  try    FTable.First;    while not FTable.EOF do begin      RecList.CurrentRowSelected := Ok;      FTable.Next;    end;  finally  FTable.GotoBookmark(book);    FTable.FreeBookmark(book);    FTable.EnableControls;  end;end; procedure TForm1.BtnCheckAll(Sender:TObject);begin  ToggleAll(true);end;procedure TForm1.BtnUnCheckAll(Sender:TObject);begin  ToggleAll(false);end; ---------------------------------------------------------------------- daveinhull · 2019-03-16 13:37 Hi jesusr, Thanks for the suggestion, but it still doesn't set the checkbox to checked or unchecked. It does something because the current record goes to the end of the list. I'm still thinking I need to some how also do the following using AState to actually check or uncheck the box. The column is not attached to a record in the table, but the bookmarklist holds the values so somehow I need to replicate the bookmarklist values into the grid checkboxes. When I select an indivdual checkbox, both UserCheckboxState and CellClick are called (see original post). 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 TForm1.DBGrid1UserCheckboxState(sender: TObject; column: TColumn; var AState: TCheckboxState);begin  if RecList.CurrentRowSelected then    AState := cbChecked  else    AState := cbUnchecked;end; Any other thoughts? Thanks Dave ---------------------------------------------------------------------- daveinhull · 2019-03-27 06:43 Hi  anyone got any thoughts on this? ---------------------------------------------------------------------- jesusr · 2019-03-27 17:14 The code I showed you is intended to work 'in addition' to the code you showed in your first msg (which if I'm not wrong corresponds to the sample code in the wikis Grids Reference Page). If you want specific help and because I cannot reproduce your problem, you can prepare a sample project I will try it here.