Data bindings are actually very simple. If you set the binding on the
foo property to
SOME_EXPRESSION, then when the
refreshing_data_bindings event triggers on your form, we execute:
self.component_1.foo = SOME_EXPRESSION
self.item = [anything] on your form automatically triggers a data binding refresh; you can also do it manually with
foo property is enabled for writeback, then when
self.component_1 raises an event that triggers that writeback (eg a CheckBox’s
change event triggers writeback on its
checked property), we execute this:
SOME_EXPRESSION = self.component_1.foo
My form has
self.item set to a row from the People table, which has a “name” column. I’ve got
self.item['name'], with writeback enabled.
self.item = person_row. This triggers an automatic data-binding refresh.
self.name_box.text = self.item['name']. The name appears in the text box.
lost_focusevent triggers data binding writeback on the
textproperty of a TextBox
self.item['name'] = self.name_box.text. This updates the database.
This article was inspired by this discussion in our community forum, where we go into more detail about custom components too.
For a more detailed discussion, see Data Bindings in the reference docs.