Good morning to all,
one more problem with our AdvStringGrid ...
This problem is on GetCheckBoxState.
If the grid is NOT filtered the function works well, but if the grid is filterd (FilterActive:=True) the function has some problems.
Here a very simple demo program (delphi 10.3 / 10.4.1 with last tmsui version ) that show this behaviour,
GridCheckBox_2020-10-28.zip (7.5 KB)
Here some code (original one)
function TAdvStringGrid.GetCheckBoxState(ACol,ARow: Integer;var State: Boolean): Boolean;
var
cg: TCellGraphic;
cp: TCellProperties;
//r: integer;
begin
Result := False;
if (NumHiddenRows > 0) then
begin
if FMouseActions.HotmailRowSelect and (ACol = 0) then
begin
State := RowSelect[ARow];
Result := true;
end
else
begin
// cp := TCellProperties(Objects[ACol,ARow]);
if FIsNarrowDown then
begin
cg := CellGraphics[ACol,ARow];
if Assigned(cg) and (cg.CellType in [ctCheckBox, ctVirtCheckBox, ctDataCheckBox]) then
begin
state := cg.CellBoolean;
end;
Exit;
end;
cp := TCellProperties(GetAllGraphicsObject(ACol,ARow));
if Assigned(cp) then
begin
cg := TCellGraphic(GetCPGraphicObject(cp));
if Assigned(cg) then
begin
if (cg.CellType = ctCheckBox) then
begin
State := cg.CellBoolean; // *1
Result := True;
end;
if (cg.CellType in [ctDataCheckBox,ctVirtCheckBox]) then
begin
State := AllCells[ACol,ARow] = GetCheckTrue(ACol,ARow);
Result := True;
end;
if (cg.CellType = ctTriStateCheckBox) then
begin
State := AllCells[ACol,ARow] = GetCheckTrue(ACol,ARow);
Result := True;
end;
if (cg.CellType = ctRowCheckBox) and (ACol = 0) then
begin
State := RowSelect[ARow];
Result := True;
end;
end;
end
else
begin
cg := GetCellGraphic(ACol, ARow); // *2
if cg = Nil then
Exit;
In my program the in *1, even if the checkbox is checked, cg.CellBoolean is always false.
But in the demo project cp := TCellProperties(GetAllGraphicsObject(ACol,ARow)); return Nil and cg is nil and the function, even the checkbox is checked, return false (*2).
Thank's for attention
Regards
Daniele