Livebindings BindScope Notification

1k Views Asked by At

To get started with live bindings i am currently writing some demo code. But at one point i have a problem where i don't find any documentation on.

I have a form with multiple TEdit's and want to bind them with an TBindScope to properties of an object. I setup the BindScope and the BindingList and everything works for the moment when i do BindExpression1.Active := true;

But now i change the properties of the object and want to notify the BindingList about an update.

Here is the Problem. I cant find any way to notify the BindingList, so it updates the values. But if i do a BindExpression1.Evaluate it synchronises the values.

I tried using

  • BindingList.Notify(BindScope, 'Object.Property')
  • BindingList.Notify(BindScope, 'Object')
  • BindingList.Notify(Object, 'Property');
  • BindingList.Notify(BindScope, 'Property');
  • BindingList.Notify(BindScope, 'Active');

Nothing seems to work for the notification.

P.S. : I know that in this case the BindScope is not necessarely needed. But since its demo code for understanding, i would like to know how it works with the BindScope.

Thanks.

1

There are 1 best solutions below

2
On

See the source code of TCustomBindScope.GetValue for details on how the scope is resolved.

  1. Component is used if assigned, otherwise
  2. DataObject is used if assigned, otherwise
  3. Owner is used

So the simplest solution is probably to leave the Component property (of your TBindScope component) unassigned and make your Object a property of the owner form.