I'm using mssql and Delphi 2009.
When a form contains a dbgrid that is connected to boolean field, the values are displayed as True, or False.
The Delphi dbgrid has the ability to translate
f
fa
fal
fals
false
t
tr
tru
true
to be true or false.
I want to add values so it can accept other strings, and match them to true or false.
Where could these values be added?
This is the default behavior for TBooleanField.DisplayValues. Look at the db unit 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. Unless you utilize OnSetText as suggested by the other answer, or use a TDbGrid.PickList.
Personally, I would use a CheckBox for Boolean field value representation on the TDBGrid.
There are plenty of examples out there on how to do that.
You could write an OnSetText event for your boolean field, and interpret any given text as True or False.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With