Live Binding and Nulls

I’ve been playing with the best way to connect our Edits with Delphi LiveBinding.

Now, if you don’t care about Nulls then our Edits connect just like the Delphi ones, from which they are descended. However, we have had Null support in our Edits since the ’90s, and in much of our client work we do treat an empty string differently than a Null.

So I tried several different types of Expression but couldn’t get things to work as nicely as I would like (of course this may well be my ignorance here). I checked out the many fine Videos available, including Cary Jensen’s latest one from CodeRage 7: – and have learnt a lot more about LiveBinding. I had played a bit with Custom Methods, but Cary mentioned in the above that it is easy to add methods to the Form (or Parent or Owner, etc) and it dawned on me, that perhaps I was approaching this wrong…

Data from the Database to the controls is passed as Variants and Variants understand Null – so I added a new Public (not published) Property:

So if you want Null support (both ways) you connect the AsVariant Property of the Edit to the AsVariant Property of the Data Field:

And similar in the Format Expression – and if the Field is Null in the Database then the Null Handling displays that as desired, and if you enter a Null into the Field then the Database gets updated with the Field set to Null 🙂

Now I haven’t played with the Visual LiveBinding introduced in XE3 but I need to get back into the Unit Conversion Engine 😉

About esbglenn

Software Developer working at our Family owned business, ESB Consultancy, which is located in Kalgoorlie-Boulder, in the Eastern Goldfields of Western Australia.
This entry was posted in Beta Development and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.