View previous topic :: View next topic |
Author |
Message |
Harri Guest
|
Posted: Tue May 03, 2005 8:17 am Post subject: Using Interface as datasource |
|
|
Currently I'm evaluating the Virtual Tree and I encounter a problem. It is essential to solve this problem for possible usage in our application.
When I try to fill the control using the visual tree editor, I've no problem when I 'Auto-generate' from on class. The tree/columns fill properly when I run my test application. However when I 'Auto generate' from an interface (which defines exactly the same functions as in the class in my test application), the control does not fill, the tree as well as the 'columns' are not filled; only the first root-item is display.
Can you tell me how to build a tree based on an interface-definition rather then a class-definition.
Thank you in advance for your answers. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue May 03, 2005 11:42 am Post subject: |
|
|
Object bindings by default bind to the type name of the object to be displayed ie the binding used is selected by matching the TypeName specified in your binding to the name of the object type.
So if you have an object of class A that implements interface B, you still need to create an object binding with TypeName set to "A" so that it is selected.
If you have multiple classes that implement the interface B and you want to use one binding for all of them you can still do this if you employ some kind of naming convention for you classes. For instance if all the classes you want to bind to implement interface B and end with _B then you could change the TypeName property of the binding to "_B".
This will work because when selecting a match the bindings will allow partial matches based on the last part of the TypeName. The bindings are also matched in the order they are displayed in the VirtualTree editor - which also gives you some more control over the way bindings are selected.
If none of this helps you could derive a new RowBinding class (eg BObjectRowBinding) from ObjectRowBinding and override the BindsTo method so that it binds to objects which implement your interface. You can then change the code generated by the designer for the interface binding to change the type declaration to BObjectRowBinding.
ObjectRowBindings should probably work in the way you expected where a full type name is specified. We can probably change this in the next minor release. _________________ Infralution Support |
|
Back to top |
|
|
Harri Guest
|
Posted: Tue May 03, 2005 2:12 pm Post subject: |
|
|
Thank you very much for your quick answer.
I've implemented a class derived from ObjectRowBinding as you suggested and now the control is filled properly!
Thanks again & best regards |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu May 26, 2005 3:45 am Post subject: |
|
|
Version 1.5.0 has now been released. It fixes the behaviour of ObjectBindings so that bindings for base classes or interfaces will bind to derived objects (or objects that implement the interface). So you no longer have to rely on naming conventions. _________________ Infralution Support |
|
Back to top |
|
|
|