View previous topic :: View next topic |
Author |
Message |
GreyCloud
Joined: 13 Nov 2008 Posts: 19
|
Posted: Mon Mar 29, 2010 11:23 am Post subject: GetRowBinding with subclass |
|
|
Hi,
I have a tree which will contain various types of node - all subclasses of the a node type i have used the object binding on - all classes share a common set of fields and so i have a common set of columns to edit these [eg name and quantity].
Code: |
// within SimTree_GetCellData
// get the default binding for the given row and use it to populate the cell data
RowBinding binding = this.SimTree.GetRowBinding(e.Row);
binding.GetCellData(e.Row, e.Column, e.CellData);
|
however GetRowBinding fails to return a row binding for the first subclass i have created.
Is this something that is simply not possible whilst using GetRowBinding?
I thought it might have something to do with the compare methods on my class hierarchy but they are not called when i expand the tree to show the node
to get arround this i suppose i can handle each of the columns manually but i'd be interested to know whats going on |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Mar 29, 2010 10:40 pm Post subject: |
|
|
If you have defined an ObjectRowBinding for the parent type then calling GetRowBinding for a row containing a derived item should work. However you do need to ensure that the ObjectRowBinding.TypeName specifies the fully qualified typename of the parent type. The ObjectRowBinding resolves the typename to a type using System.Type.GetType(typeName).
If it is unable to resolve the TypeName to a type then the ObjectRowBinding fallsback to string matching based on the last part of the item typename ie if your base class is "MyNamespace.MyBase" and your derived class is "MyNamespace.MyDerivedBase" then if you specified TypeName = "Base" this would match any class name ending with "Base".
If you want to handle the binding process yourself then you can handle the GetBinding event. _________________ Infralution Support |
|
Back to top |
|
|
GreyCloud
Joined: 13 Nov 2008 Posts: 19
|
Posted: Tue Mar 30, 2010 11:51 am Post subject: |
|
|
Thanks, that's got it - it had fallen victim to some over zealous ReSharper Refactoring i did a few weeks back
I had "Project.Nodes.SimNode" but not "Project.Nodes.SimNode, Project"
what is the ", Project" part do ? is it the assembly? |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Mar 30, 2010 9:49 pm Post subject: |
|
|
Yes that is the assembly. _________________ Infralution Support |
|
Back to top |
|
|
|