How can I access another form's BO in a form?


Author
Message
Ben Hayat
Ben Hayat
Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
I must be missing something that I can't see or reference a form or variable from another form's BO.



In my Main form, I have a BO that acts as the parent to several other BOs that are in other forms. My question is in two fold:

a) In the employee form, when I drop a BO, how can I tell it in designer that the "ParentBusinessObject" is the one in Main Form?

b) By the same token, in this employee form, how do I access the BO in the Main form and other public variables I had set.



Somehow I'm need to tell Employee form to reference to Main form.



I think Randy had the same problem, and I had given him a solution that doesn't even work for myself.



Thanks!

..ßen
Replies
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
By my guess, it looks like the main form is going to be creating and showing the instances of the other forms.  There isn't a way within the designer to tell a component on one form to reference a component on another form (the form designer does not know that the other form exists.  So, you will have to set the parent programmatically.  Your best bet would be to add a parameter to your child forms' constructors that accepts the parent business object; then set the ParentBusinessObject property on the child BOs after the InitializeComponent has been called.  Then, all you need to do is pass over the parent business object when you create new instances of the child forms.
Ben Hayat
Ben Hayat
Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
Ben Chase (06/06/2007)
By my guess, it looks like the main form is going to be creating and showing the instances of the other forms. There isn't a way within the designer to tell a component on one form to reference a component on another form (the form designer does not know that the other form exists. So, you will have to set the parent programmatically. Your best bet would be to add a parameter to your child forms' constructors that accepts the parent business object; then set the ParentBusinessObjectproperty on the child BOs after the InitializeComponent has been called. Then, all you need to do is pass over the parent business object when you create new instances of the child forms.




Ben, I'll look into this further probably this weekend and if I have more questions, I'll ask next week. But you gave me a good starting point!

Thanks!

..ßen
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Ben Hayat - 18 Years Ago
Ben Hayat - 18 Years Ago
Greg McGuffey - 18 Years Ago
Ben Hayat - 18 Years Ago
Greg McGuffey - 18 Years Ago
                         Greg; Thank you very much for your time and effort;

I'll be...
Ben Hayat - 18 Years Ago
                             By my guess, it looks like the main form is going to be creating and...
StrataFrame Team - 18 Years Ago
                                 [quote][b]Ben Chase (06/06/2007)[/b][hr]By my guess, it looks like the...
Ben Hayat - 18 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search