Lasse_Holm
(Lasse Holm)
September 16, 2013, 4:52am
1
Hello,
Could anyone point me to how to place checkboxes in a virtual grid?
I need a column that is always a boolean value and it should always display as checkboxes.
I use the On GetCheckFalse/OnGetCheckTrue events.
I can do it with Grid.AddCheckBoxColumn, but it this really necessary? (Doesn't seem to always work properly, anyway).
If you do not want to add the checkboxes, you'd need to create a class that descends from TAdvStringGrid and override the function GetCellGraphic and for cells that are virtual checkboxes, return ctVirtCheckBox for this function.
Lasse_Holm
(Lasse Holm)
September 17, 2013, 8:45am
3
Thanks.
I have now added a OnGetIsCellCheckbox to the descending grid class.
The overridden GetCellGraphic uses the value returned by OnGetIsCellCheckbox to determine if a virtual checkbox should be shown:
function TMyAdvStringGrid.GetCellGraphic(ACol, ARow: Integer): TCellGraphic;
begin
RESULT := inherited GetCellGraphic(ACol,ARow);
if IsCheckboxCell(ACol,ARow) then
begin
if RESULT=nil then
RESULT := TCellGraphic.Create;
RESULT.CellType := ctVirtCheckBox;
end;
end;
(It would be nice if something like this was already implemented in TAdvStringGrid)
Thank you for your help.