I wanted to display and edit a boolean value from a dataset using a checkbox inside the grid. The dataset is a query from a SQLite database. Delphi does the major haul mapping the boolean value TBooleanField. Thus, we can assign boolean values to the field.
TDBAdvGrid has an editor (just like any other third party grid) for checkboxes. Yet again, the flexibility of the control is working against us. If you simply set the editor property to “edCheckBox” editing will fail. If you click the checkbox, nothing will happen. The reason for this is rather easy, but tricky to find. The column has two properties called “CheckFalse” and “CheckTrue”. The values of the properties have to be set to the representation of False and True. The default values are as follows:
This setting works fine for databases that use Y and N to represent True and False. SQLite uses True and False. Thus, setting the properties to “False” and “True” will yield the result desired.
Of course, another aspect with regard to the implementation of TDBAdvGrid is the fact that you can use the edCheckBox-editor with any datafield, the type of the field does not matter. The only requirement is that the field needs to be able to store two different values, one for true and one for false.
When working with visual components a lot of work is taken out of our hands. However, sometimes that ease is exactly what makes finding an issue difficult.