TMSFNCDataGrid get CheckBox state

Hi,

I'm trying to get the state of a checkbox in a cell... but, I do not know how.

TMSFMCDataGrid1.AddCheckBox(col, row, True);
CellChecked := TTMSFNCDataGridCheckBoxCell(TFDGridApps.CellData[col, row]).Checked;

Trying these code, CellChecked is allways False...

Using TTMSFNCGrid you can get/set it with CheckBoxState[col, row].

Using TTMSFNCDataGrid you can set with SetCheckBox(col, row, value) but there is not GetCheckBox function

TIA
Ricardo

Hi,

The CellData property stores data from the cell, but the type is incorrect. The type is TTMSFNCDataGridCellItem for the base type, and TTMSFNCDataGridCellItemExtended for the extended type. The extended type is used as soon as you add checkboxes, radiobuttons, etc... . Alternatively, you can get the cell and directly check the state of the checkbox, but the cell will only be accessible when its visible, or use the Booleans property. So you have a few options:

  1. Typecast to extended cell item type
b := False;
if IsExtendedCell(TMSFNCDataGrid1.CellData[col, row]) then
  b := AsExtendedCell(TMSFNCDataGrid1.CellData[col, row]).BooleanValue;
  1. Only accessible when the cell is visible
b := False;
if TMSFNCDataGrid1.GetCellObjectForCell(MakeCell(col, row)).IsCheckBoxCell then
  b := TMSFNCDataGrid1.GetCellObjectForCell(MakeCell(col, row)).AsCheckBoxCell.Checked;
  1. Use the Booleans property (recommended)
b := TMSFNCDataGrid1.Booleans[col, row];

Thank you very much, Pieter.

TMSFNCDataGrid1.Booleans[col, row] is good for me. It works like TMSFNCGrid1.CheckBoxState[col, row]

1 Like

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