Malcolm Groves has a blog post up where he demonstrates how to convert the display of a field from an integer to a boolean with Delphi XE5 Firemonkey. Should also work with Delphi XE6 and AppMethod. The way it works is that the same field (IntegerField from the demo) is bound to to a column in a grid. There is an outbound property called CustomFormat and an inbount property called CustomParse. In the CustomFormat field you put ToStr(%s) <> “0” and in the CustomParse field you put IfThen(ToStr(%s) = “True”, -1, 0). The properties take kind of a macro language where %s is the value to be modified and then you can use various different functions on the value. In this case a To String function and a If Then function. There are more screenshots you can check out which will make it more clear. Check out the source code here. One of the comments from Mathias on the blog post points out a different way to accomplish the Integer to Boolean functionality with LiveBindings and it also includes a demo. One plus about this second demo is that it applies the integer to boolean conversion through your entire project instead of having to set it up for each field like the first method. Both of these methods should work cross platform on Android, IOS, Windows, and OSX. Here is some sample code from the second demo:
procedure(const I: TValue; var O: TValue)
if I.AsBoolean then
O := TValue.From<String>('-1')
O := TValue.From<String>('0');
'BoolToString', 'BoolToString', EmptyStr, True, EmptyStr, nil)
LiveBindings Convert Integer Field To Boolean With Delphi XE5 Firemonkey On Android And IOS by Delphi XE5 XE6 XE7 XE8 10 Seattle Berlin Firemonkey, Delphi Android, Delphi IOS is licensed under a Creative Commons Attribution 4.0 International License.