Delphi dbgrid boolean value, accept f fa fal fals false, how to accept more values?

I use mssql and Delphi 2009. When the form contains a dbgrid that is associated with a boolean field, the values ​​are displayed as True or False . Delphi dbgrid has the ability to translate

 f fa fal fals false t tr tru true 

will be True or False . I want to add values ​​so that it can take other strings and match them with True or False . Where can I add these values?

+7
source share
2 answers

This is the default behavior for TBooleanField.DisplayValues . Look at the db source:
db.TBooleanField.SetAsString and db.TBooleanField.SetDisplayValues .

If you set TField.DisplayValues := 'Yes;No'; , for example: Y , Ye , Yes will represent True ; N , No will represent False .

You cannot add more values ​​to it. If you are not using OnSetText , as suggested by another answer, or use TDbGrid.PickList .

Personally, I would use a CheckBox to represent the value of a logical field on a TDBGrid .
There are many examples on how to do this.

+9
source

You can write an OnSetText event for your boolean field and interpret any given text as True or False .

+2
source

All Articles