FNC Grid Checkboxes

Hi...

My grid has some boolean values which I like to toggle with a checkbox column. The state of the checkboxes change if I click them, however, the underlying cell values apparently do not change... I like to toggle between 0 and 1. What am I missing?


Sorry, my fault. The cell values are indeed updated and either contain FALSE or TRUE. I didn't see it because I was testing for 0 and 1... :/

However, do now have another question... If Grid is set to Options.Editing.Enabled := FALSE, the checkboxes can still be clicked. Is this by design?




That is true, the Editing.Enabled property is for inplace editing, which means the editor that is shown when clicking a cell. To disable editing on checkboxes please use the following code:




procedure TForm26.TMSFNCGrid1GetCellProperties(Sender: TObject; ACol,
  ARow: Integer; Cell: TTMSFNCGridCell);
begin
  if (Cell is TTMSFNCCheckGridCell) then
    (Cell as TTMSFNCCheckGridCell).ControlEnabled := False;
end;

Thanks for your quick reply. I tried your solution, however, it doesn't work properly.
I am contolling the edit state of the grid with a button. After setting the edit state from TRUE to FALSE, I still can click one more time on a checkbox. Only after the second click the checkbox is disabled.

var
  Form1: TForm1;
  bEditing: Boolean = TRUE;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.TMSFNCButton1Click(Sender: TObject);
begin
  bEditing := FALSE;
end;

procedure TForm1.TMSFNCGrid1GetCellProperties(Sender: TObject; ACol,
  ARow: Integer; Cell: TTMSFNCGridCell);
begin
  if not bEditing then
    if (Cell is TTMSFNCCheckGridCell) then
    (Cell as TTMSFNCCheckGridCell).ControlEnabled := False;
end;              



You need to wrap the code with BeginUpdate & EndUpdate. simply setting the bEditing property will not trigger the OnGetCellProperties:



TMSFNCGrid1.BeginUpdate;
bEditing := FALSE;
TMSFNCGrid1.EndUpdate;

Thanks, that helped... ;)