StrataFrame Forum

Child Form and ChildFormDialog Questions

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

By Terry Bottorff - 3/22/2010

I have a parent form with a listview of people (working). Now I need to add some child Bo's and some child forms that will be called by childformdialogs. First can you have more then one Child Bo on a form? This question was asked on the forum before but I never found an answer.

Second, if you just want to show the persons name from the parent BO and parent form, on the child form so the user will have a reference to who they are working on. Is that possible? Some how you would have to have a reference to the parent BO.

TIA.

I had a problem wording this so if I am not clear let me know. Again Thank you.
By Edhy Rijo - 3/22/2010

Terry Bottorff (03/22/2010)
I have a parent form with a listview of people (working). Now I need to add some child Bo's and some child forms that will be called by childformdialogs. First can you have more then one Child Bo on a form? This question was asked on the forum before but I never found an answer.

Second, if you just want to show the persons name from the parent BO and parent form, on the child form so the user will have a reference to who they are working on. Is that possible? Some how you would have to have a reference to the parent BO.

TIA.

I had a problem wording this so if I am not clear let me know. Again Thank you.


Hi Terry,



Yes, you can have as many child BO as you want in a form, and to make a reference to the parent record, just add the parent BO to the child BO and use the BO translation editor of the ChildFormDialog to also translate the parent record to the instance BO in the child form, this way you will have access to the whole parent record all the time.


By Terry Bottorff - 3/22/2010

Edhy is there code somewhere so I can see how to do:

" just add the parent BO to the child BO and use the BO translation editor"

??? I think I just add it as another translation when I tell the childformdialog about the childBO and the BO on the child form using BusinessObjectTranslations.... Am I correct?



"add the parent BO to the child BO" this say child form?

If so then I think I know how to try this but how do I make sure the parent BO is on the correct record when it translates it?

TIA.
By Edhy Rijo - 3/22/2010

Terry Bottorff (03/22/2010)
Edhy is there code somewhere so I can see how to do:

" just add the parent BO to the child BO and use the BO translation editor"

??? I think I just add it as another translation when I tell the childformdialog about the childBO and the BO on the child form using BusinessObjectTranslations.... Am I correct?


Yes, you are correct, just use the translation in the ChildFormDialog. The beauty of this is that you can translate as many BOs as you need.



Terry Bottorff (03/22/2010)
"add the parent BO to the child BO" this say child form?

If so then I think I know how to try this but how do I make sure the parent BO is on the correct record when it translates it?


Yes in the child form, you can also add as many BO as you want including the Parent BO. When the ChildFormDialog opens the child form, it will translate the defined BOs and they all will be in the original current record.



About samples, you can use the StrataFlix forms which use ChildFormDialog, this is a very nice and smart approach and in fact very easy for the developer to deal with the data at any form level.
By Terry Bottorff - 3/23/2010

Edhy I want to thank you for your help. I got pass that hurdle but now I have a New one. When I click the button to show the child form I get the following error.

Object of type RodeoBOLib.BBPointschildBO cannot be converted to type RodeoBOLib.BBPointsBO.



Do the Bo's have to have the same name? I have checked and both point to the same database table. I have checked the translation in the childformdialog.BusinessObjectTranslations (have attached pictures of the error and the translation). Am I missing something?

TIA.
By Edhy Rijo - 3/23/2010

Hi Terry,



I don't think the name of the BO has nothing to do since what is being check is their Types based on the same BO. I am pretty sure either your BO is not setup correctly. I would suggest doing the following:

1.- Delete the ChildFormDialog from the Parent form.

2.- Delete all BO involved in the ChildFormDialog from both forms.

3.- Save your forms, close the solution and exit Visual Studio.



4.- Open your solution and start over again.

5.- Make sure your BOs are correct.



For me it does not make sense to change the name of a BO unless there is a pretty good reason that would make sense to the form's logic. Trust me I have done this many times, it is pretty easy to do and better yet, it does work, so keep trying until you get it done! Tongue


By Terry Bottorff - 3/23/2010

OK I will try it and get back to you. I changed names only because I just wanted to make sure I could keep track since this is the first time I used childdialogform......
By Edhy Rijo - 3/23/2010

Terry Bottorff (03/23/2010)
... I changed names only because I just wanted to make sure I could keep track since this is the first time I used childdialogform......




I understand, but in my case I found that is clear to have the same BO names in forms where those BOs will be translated, it just easier to the eyes to map the BOs with the same name.
By Terry Bottorff - 3/24/2010

OK I decided to redo this Whole Thing so I created a brand new Project. Put the Listview on the parent form, the childformdialog and the BO's. Created a Child Form with the BO's and a listview to see the Child Data. It all Worked fine so I know I can recreate it in the original Project.

BUT:

I decided I want to try a DataGridView and a DevExpressXtraGrid on the child form. I put a Business Binding Source on the Child form and set it's BO to the ChildBo. Then set the Datasource for each grid to the BBS. No Rows of data show. ????? Does it have to do with when the data is loaded into the BBS? If so how can I get the data to show up in the Grids?



TIA. Everyone is so good with their help on this forum......!
By Edhy Rijo - 3/24/2010

Hi Terry,



I am glad the ChildFormDialog is working for you.



About the datagridview I am not really a big fan and in fact when I tried to used it in a couple of occasions it was so frustrating that I end up using a ListView and a ChildFormDialog. I know there are uses for the DataGridView but I am just out of luck with them. BigGrin
By Dustin Taylor - 3/26/2010

Sounds like a bootstrap problem to me Smile. Try re-binding the BBS to the BO in the OnLoad of the child form and see what results you get.

So, something like:

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //-- Rebind my BBS to the BO        
            MyBBS.BusinessObject = MyChildBO;     
        }

You may also need to requery your grid to re-pull the data from the newly re-bound BBS after you do that.

Basically, what I think is happening is that the BBS (and therefore the grid) is getting bound to an empty instance of the childBO.  The ChildFormDialog then creates a second instance of the childBO populated with the data from the parent form. Since the BBS is never updated to point to this new, populated instance, the data is not being reflected in your grid.