StrataFrame Forum

How to access another form's Business Object?

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

By Lukasz Kustusz - 9/28/2010

Hello,

I have a form that is used to insert to it's primary BO. Only some of the fields would be populated from the form's UI. The rest I'd like to set from a parent form when I show the child form. How do I refer to the child form's BO from the parent form?
By Greg McGuffey - 9/28/2010

The first thing I'd look into is using a ChildFormDialog. This can manage parent child relationships pretty easily. Take a look at the help topic on this control (Application Framework - UI Layer - Controls).

To more directly answer the question, in the property window for the BO instance on the form and set its Modifiers to Public. Then, if you have an instance of the form, the BO will be a property of that instance.
By Lukasz Kustusz - 9/29/2010

Thank you for your replay. I did consider using a ChildFormDialog for this problem, but the thing is that in my parent form my bo is wrapped in the custom business binding source, and therefore it is not visible at design time, during the configuration of the ChildFormDialog. If there's a way to work around that, let me know.
By Greg McGuffey - 9/29/2010

Hmmm...well, this is sounding interesting and the ChildFormDialog may not be the way to go. Another option I thought of was to pass the parent BO to the child form in a constructor, then set the parent BO to a property of the child form:

Public Class MyChildForm

    Public Sub New(parentBO As MyParentBOType)
        Me.ParentBO = parentBO
    End Sub

    Private _parentBO As MyParentBOType
    Public Property ParentBO As MyParentBOType
        Get
            Return _parentBO
        End Get
        Set(value As MyParentBOType)
            _parentBO = value
        End Set
    End Property
End Class