Calculating Properties from a Child List

Calculating Properties from a Child List

Old forum URL: forums.lhotka.net/forums/t/6590.aspx


BarryC posted on Wednesday, March 11, 2009

Hi All,

I am developing a system where some of the properties in a parent object are calculated from properties of child objects in a child list.  The parent properties must be updated whenever one of the corresponding properties in the child list is altered and whenever a child object is added or deleted from the list.

Does anybody know how I should go about this?

Thanks,

Barry C

wilfreds replied on Wednesday, March 11, 2009


If you use the latest version of the framework you can use managed properties.

So, in this vb sample you would listen to the events sent to _ChildList to update your parent object.

    ' declare child member(s)

    Private WithEvents _ChildList As ChildList = Library.ChildList.NewChildList(Me)

 

    Private Shared ChildListProperty As PropertyInfo(Of ChildList) = RegisterProperty(New PropertyInfo(Of ChildList)("ChildList"))

    Public ReadOnly Property ChildList() As ChildList

        Get

          If Not FieldManager.FieldExists(ChildListProperty) Then

            LoadProperty(Of ChildList)(ChildListProperty, _ChildList)

          End If

          Return GetProperty(Of ChildList)(ChildListProperty)

        End Get

    End Property

Copyright (c) Marimer LLC