StrataFrame Forum

Question about subclassed panel and BO binding...

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

By Robin J Giltner - 10/27/2006

I have a small question regarding a panel I have successfully managed to subclass (ok well almost successfully).  After taking the code from the form designer for the panel, and making sticking it into a class, and altering the code to simply get the form to show up properly, I've run into a problem.  The panel has controls bound to a BO that is located on the form, how can I tell the panel class to use these BusinessObjects?

So far, I've changed my Initialization method on the panel class to accept a BusinessLayer object, and changed my New constructor to accept a generic BusinessLayer.  After that, I had to go back into the form's designer and add the parameter to where the panel class gets instantiated to pass it the BO from the Form.

After reviewing all of the steps I took, I figured there is a better way of doing this and was hoping you could point me into the right direction.

Thanks.

Robin Giltner

By Trent L. Taylor - 10/27/2006

The panel has controls bound to a BO that is located on the form, how can I tell the panel class to use these BusinessObjects?

This will be more difficult using a Panel...the easiest thing to do is to create an SF User Control class, the place your panel on that user control.  All SF user controls have a BOTranslations property that allows business objects to be translated from a form to the dropped on user control. 

For example, you would create your user control and drop any BOs that you plan to use on this control.  You can bind to these BOs just as though you were on a form.  Once you get the user control where you like it, drop it on a form (or another control, etc.).  Once the control is dropped on the form, go to the BOTranslations property of the control and use the type editor (builder) that comes up to translate the BOs on your form to the BOs within the user control.  So at runtime, the BO instances on the form will automatically translated onto the user control without you having to write a single line of code.

By Robin J Giltner - 10/27/2006

Awesome, Thanks Trent.  I'll give that a try.  One quick question, I can translate multiple businessobject from the form to the UserControl right?

Thanks,

Robin Giltner

By Trent L. Taylor - 10/27/2006

As many as you would like...go until you run out of memory BigGrin
By Robin J Giltner - 10/27/2006

YES!  I can add as many BusinessObjects to my UserForm as it takes to run out of memory then blame you guys for the problem! 


THE DAY IS MINE! BigGrin

Thanks again.

Robin

By Trent L. Taylor - 10/27/2006

hehe....yup, you pretty much nailed it Smile
By Robin J Giltner - 10/27/2006

Another small question, this will work for a PanelManagerPage as well?

Thanks,

Robin

By Trent L. Taylor - 10/27/2006

No.  You would have to drop a user control on a PanelManagerPage.