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 used
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
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;