Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Binding to ancestor of actual class instance

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
RGabo



Joined: 21 Sep 2005
Posts: 11

PostPosted: Thu Jul 06, 2006 11:04 am    Post subject: Binding to ancestor of actual class instance Reply with quote

Hey,

I have an object model where I have an abstract class Foo and different implementations of that abstract class come from different sources.

I would like to be able to bind to the Foo abstract class and its (abstract) properties. It seems to me that all that happens when I have a binding to Foo and not the actual Foo-derived class is that virtual tree puts foo.ToString() in the first column but doesn't even try to make use of the column-object bindings.

What I have to do now is to not do any binding but use events like GetRowData and GetCellData. It would be nice if the common stuff in my abstract Foo clas could be bound, whenever Foo-derived objects show up in the data source.

Thanks,
Gabor
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Jul 06, 2006 10:37 pm    Post subject: Reply with quote

You can bind to abstract classes and interfaces – it’s just that the behaviour of System.Type.GetType(name) can be a bit erratic. Virtual Tree resolves the name you set in the binding to a type using Type.GetType() and then checks whether this type is assignable from the object being bound. If GetType returns null (as it does for some reason sometimes with abstract classes) then Virtual Tree will bind based on whether the type name you specified matches the concrete typename of the object being bound (this won't work for abstract classes).

The good news is that its easy to fix this by specifying the TypeName more completely by including the assembly name (eg “MyNamespace.MyType, MyAssemblyName”). Then GetType() will work. An alternative is to set the binding.Type property directly (programmatically) after the InitializeComponent call.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group