StrataFrame Forum

Custom BO field

http://forum.strataframe.net/Topic3570.aspx

By Jon Olson - 10/13/2006

I added a Custom code to my field for a lookup but now I get an error saying I need a fieldpropertydescriptor. How do I fix this (vb.net project)
By StrataFrame Team - 10/13/2006

Sorry, Jon, I'm just too lazy to type it again...

http://forum.strataframe.net/FindPost3479.aspx

By Jon Olson - 10/13/2006

Thanks, I saw that before actually. I am just not  sure how to convert that to vb.net

This is what I have so far but it doesnt like boCalc.

Protected Overrides Function GetCustomBindablePropertyDescriptors() As FieldPropertyDescriptor()

Return New ReflectionPropertyDescriptor("Ctr", Type.GetType(boCalc))

End Function

By Jon Olson - 10/13/2006

Okay I figured it out.

 

Protected Overrides Function GetCustomBindablePropertyDescriptors() As FieldPropertyDescriptor()

Return New FieldPropertyDescriptor() {New ReflectionPropertyDescriptor("Ctr", GetType(boCalc))}

End Function

By StrataFrame Team - 10/13/2006

Excellent, I'm glad you figured it out.  We usually post everything in VB.NET, but I think the person that that post was answering was a C# guy...

As for the Type.GetType(boCalc), it's a shared (static) method on the System.Type class, and it only accepts strings, but the GetType(boCalc) is a language keyword, so it accepts the type and knows how to compile it.

And you figured out the creating a new array rather than returinging only a single instance. Smile

By Jon Olson - 10/16/2006

I tried adding a second custom field to the BO, I am not sure how to add the code to make it work

I tried somthing like this but doesnt work

Protected Overrides Function GetCustomBindablePropertyDescriptors() As FieldPropertyDescriptor()

Return New FieldPropertyDescriptor() {New ReflectionPropertyDescriptor("Ctr", GetType(boCalc))}

Return New FieldPropertyDescriptor() {New ReflectionPropertyDescriptor("Ftr", GetType(boCalc))}

End Function

 

By StrataFrame Team - 10/16/2006

Inside the curly braces, just separate the return objects with a comma... it adds them to the array.

This:

New FieldPropertyDescriptor() { }

Tells it to create a new array of type FieldPropertyDescriptor.  Whatever you put in the curly braces are items in the newly created array (ReflectionPropertyDescriptor is a subclass of FieldPropertyDescriptor).  So, it needs to look like this:

Return New FieldPropertyDescriptor() { New ReflectionPropertyDescriptor("Ctr", GetType(boCalc)), _
    New ReflectionPropertyDescriptor("Ftr", GetType(boCalc)) }

Any others that you add just need to be separated by commas.