StrataFrame Forum

Override Property Setter

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

By Ben Kim - 2/28/2007

Hello all,

Is there a way to override a BO property Setter?  I have tried copying the Property I want to modify into the BO.vb (not the designer file) and apply Overrides to the public property method.  This of course does not compile since the base property is not overridable.

What I would like to do is if a value is changed, automatically UPPERCASE and PadLeft(3) the field, plus call a function to set another field:

Example Setter:

Me.CurrentRow.Item("HairColor") = value.ToUpper.PadLeft(3)
Me.HairColorDescription = GetLookupItem(DepartmentID, TableNumber, Me.CurrentRow.Item("HairColor"))

My initial thought was to UpperCase and Pad the field in the CheckRulesOnCurrentRow event.

Me.HairColor = Me.HairColor.ToUpper.PadLeft(3) !Pad left for sorting purposes
Me.HairColorDescription = GetLookupItem(DepartmentID, TableNumber, Me.HairColor)

The above works.  However as I navigate through the records (even after copying the code to the BO Navigated event), the description seems to always be one behind the current record.  Custom fields and property descriptions have been setup and work so this is not the issue either.

Ideas?

Thanks!

Ben

By StrataFrame Team - 2/28/2007

You can customize the field through the BOMapper and paste your code into the custom code field.  Then, when the partial class is built, the BOMapper will spit out the custom code rather than the generated code for that property.  You can also choose custom code and just put a comment or a couple line breaks in the custom code box and just put your property in the main code file.
By Greg McGuffey - 3/1/2007

Do you put the entire property statement in the custom code box (i.e. Public Property MyField() As Integer...etc.)? Or just get/set statements?
By Ben Kim - 3/1/2007

Yes.  However I had issues after doing so.  The editing state of the form seemed to screw up and the lookup did not happen at all when I moved my code to the "property setter/getter" area.

I reverted my code back to the original form...  Handle trimming/padding in the CheckRulesOnCurrentRow, and all calls to lookup descriptions for "codes" are done back in the Maintenance Form now.  All is well now... No more "EditingState" errors ;-)

Ben