FNCDataGrid Checkbox OnGetCellFormatting issue

Hi,

My FNCDataGrid has the selection mode of type gsmDisjunctRow.
I have added a checkbox column and an OnGetCellCheckBoxChange to my grid thus:

procedure TForm1.GridCellCheckBoxChange(Sender: TObject; AColumn,
  ARow: Integer);
var
  b:Boolean;
  i:integer;
begin
  b:=Grid.Booleans[AColumn, ARow];
  Grid.SelectedRows[ARow]:=b;
end;

i.e. when the checkbox is selected, select the row.
If I ask for a count of Grid.SelectedRows, this works as expected.

However, I want to hide the true/false text, so I added the following OnGetCellFormatting routine:

procedure TForm1.GridGetCellFormatting(Sender: TObject;
  ACell: TTMSFNCDataGridCellCoord; AData: TTMSFNCDataGridCellValue;
  var AFormatting: TTMSFNCDataGridDataFormatting;
  var AConvertSettings: TFormatSettings; var ACanFormat: Boolean);
begin
  ACanFormat:=True;
  if ACell.Column=Grid.ColumnIndexByName(SEL) then
    begin
      AFormatting.&Type:=gdftBoolean;
      AFormatting.BooleanTrueText:=' ';
      AFormatting.BooleanFalseText:=' ';
    end;
end;

And this works as expected and hides the text, leaving only checkboxes.

However, when I do the .GetSelectedRows routine, the result is always 0;

Is this an error or have I done something wrong?

Thanks!

Since the cell formatting is effectively responsible for the text to boolean & vice versa you cannot change the formatting. You can hide the text via

procedure TForm1.TMSFNCDataGrid1BeforeDrawCell(Sender: TObject;
  AGraphics: TTMSFNCGraphics; ACell: TTMSFNCDataGridCell;
  var ACanDraw: Boolean);
begin
  ACell.DrawElements := ACell.DrawElements - [gcdText];
end;

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.