﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Tutorial 14 (Configuring a Business Object relationship)</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 08:51:50 GMT</lastBuildDate><ttl>20</ttl><item><title>Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost980.aspx</link><description>I just finished tutorial 14, Configuring a Business Object relationship, and when i got to the end it said "Designing a child form that will show use of a business object relationship is beyond the scope of this tutorial". Well I've looked through the help file and the forums and can't find a parent-child tutorial.  &lt;br&gt;
&lt;br&gt;
So my question is how do i create a form with two grids on it to demonstrate how this business object relationship works.</description><pubDate>Tue, 02 May 2006 13:48:16 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1057.aspx</link><description>Yes, this thread seems to be more of a chat window :)&lt;br&gt;
&lt;br&gt;
Basically, there are two methods you can use to accomplish what you're trying to do:&lt;br&gt;
&lt;br&gt;
1)  Fill both business objects in their respective ParentFormLoading events.  Use the relationship and the ChildAutoFilterOption to let the parent business object filter the children.  This is the option you want to use to reduce network traffic and requeries against the database.  However, if you have several thousand child records, this wouldn't be the option you would want to use.&lt;br&gt;
&lt;br&gt;
2)  Fill just the parent business object in its ParentFormLoading event.  Then, in its Navigated event, fill the child business object will only the records that belong to the current parent, say, using the FillByParentPrimaryKey() method on the child business object and passing it the current pk of the parent.  This is the method you want to use if you don't care about network traffic or you have several thousand child records, since you don't have to bring them across all at the same time.  &lt;br&gt;
&lt;br&gt;
Method #2 is the method that the tutorial is using, while Method #1 is the way you're sample is handling the issue.  Both are correct, and both have their uses, but you can't mix them because it could cause problems with the order that the filter is being set and the child is being filled.</description><pubDate>Tue, 02 May 2006 13:48:16 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1055.aspx</link><description>Sorry, I dont understand. I have the SQL statements in the business objects that will be used to fill them.  Then in the form I call those Fill methods in each BO's ParentFormLoading Event.  You're saying not to fill the BO's on load?&lt;br&gt;
&lt;br&gt;
This thread seems like its taking on a life of its own.  :P</description><pubDate>Tue, 02 May 2006 13:03:34 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1054.aspx</link><description>I believe that there is already code within the Navigate method on that form that's requerying the database for the orders.  You can either requery like that form is doing, or you can fill the parent and child with all of the necessary records and then let the child filtering do its thing.  But, if you try to use both methods, you're going to run into problems.</description><pubDate>Tue, 02 May 2006 12:53:51 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1053.aspx</link><description>I've checked both those things and they were set properly.  I turned the ChildAutofilter property off and ran the program and it worked fine.  I was able to navigate the customer form and the all the orders filled the grid.  When I set ChildAutoFilter to MatchCurrentRow I got the attaced error.</description><pubDate>Tue, 02 May 2006 12:32:40 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1050.aspx</link><description>Make sure that the IncludeInFormNavigateType property on the CustomerMaintenance form is set to PrimaryBusinessObject and make sure that CustomersBO1 is set as the PrimaryBusinessObject on the form.  For some reason, it looks like your form thinks it's supposed to be navigating Orders instead of Customers.</description><pubDate>Tue, 02 May 2006 09:38:15 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1049.aspx</link><description>[quote]As for the child grid not being cleared when you select a record that has no child records, put a handler on the TitlesBO.FilterChanged event and within it, put a message box, or a Debug.WriteLine() call within it and print the TitlesBO.Filter value. Basically, I want to make sure the filter is being set whenever you select a record that doesn't have any child records.[/quote]&lt;br&gt;
&lt;br&gt;
I'll try that.&lt;br&gt;
&lt;br&gt;
Another question.  I have the Customer Maintenance form and I have a parent child relationship setup with the Orders table.  There is a grid on the maintenance form that displays the customers orders.  I have everything setup correctly (i think) and when i run the program there is no errors but the navigation buttons are disabled.  The first customer doesnt have any related orders.  I dont know if that has anything to do with it.</description><pubDate>Tue, 02 May 2006 09:27:38 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1045.aspx</link><description>As for the child grid not being cleared when you select a record that has no child records, put a handler on the TitlesBO.FilterChanged event and within it, put a message box, or a Debug.WriteLine() call within it and print the TitlesBO.Filter value.  Basically, I want to make sure the filter is being set whenever you select a record that doesn't have any child records.</description><pubDate>Tue, 02 May 2006 08:26:57 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1044.aspx</link><description>The error you're getting when trying to insert the child record is because the Titles business object is configured with PrimaryKeyIsAutoIncremented = True, and the primary key can only be auto-incremented for numeric data types.  Since the primary key is not an auto-incremented value, you'll need to set the PrimaryKeyIsAutoIncremented property to False and assign a valid PK value for the new child record before saving.  Basically, the server cannot assign the PK value, you'll have to assign it on the client side.</description><pubDate>Tue, 02 May 2006 08:25:05 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1041.aspx</link><description>Thanks Ben, I'll look into that.  I posted two things in a row.  Please look at post 1033.&lt;br&gt;
&lt;br&gt;
[url]http://forum.strataframe.net/FindPost1033.aspx[/url]</description><pubDate>Tue, 02 May 2006 07:26:03 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1036.aspx</link><description>You wouldn't need to put any code there because the navigation buttons on the MaintenanceFormToolstrip call the Navigate() methods on the business object(s), so the Navigated event is already getting raised (which re-filters the children automatically).  The reason you have handle events on the parent grid in your scenario is because of the flat list problem... the grid doesn't need to navigate records, so you have to Navigate the business object manually.  With the maintenance form toolstrip, and the way the CustomerMaintenance form works, you have to call Navigate to move to another record.</description><pubDate>Mon, 01 May 2006 16:40:36 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1035.aspx</link><description>And another question.... If I wanted to put an Orders grid at the bottom of the CustomerMaintenance form found in the Tutorials what event from the Maintenance form would I use to put my ParentBO.Navigate code in? So that the orders would refresh each time i went to a different customer.&lt;br&gt;
&lt;br&gt;
Thanks</description><pubDate>Mon, 01 May 2006 16:00:23 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1033.aspx</link><description>Thanks, works now.  A couple related questions.  When I move to a record in the parent grid that doesnt have related child records it doesnt clear the grid, it just leaves the records from the previous record.&lt;br&gt;
&lt;br&gt;
Plus when I tried to add a child record I got an error.  I have attached a screen shot of that error.  Keep in mind that I am using the pubs database and my parent is Publishers and my child is Titles.  I think it has something to do with the primary key in Titles being Alphanumeric.  Not sure how to resolve the problem though.&lt;br&gt;
&lt;br&gt;
Thanks</description><pubDate>Mon, 01 May 2006 15:25:37 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1026.aspx</link><description>Ah, yes, I assume you're using the .NET DataGridView, correct?&lt;br&gt;
&lt;br&gt;
The business objects do not automatically attach to the events on the grids, and the grids do not notify the business objects to navigate, since the grid views the business object as a big, flat list.  So, within the RowClicked and/or CellClicked events of the grid, you will need to call:&lt;br&gt;
&lt;br&gt;
ParentBO.Navigate(BusinessNavigationDirection.Absolute, e.RowIndex) &lt;br&gt;
&lt;br&gt;
This will tell the business object to navigate to the desired record, thereby synching with the child business object.</description><pubDate>Mon, 01 May 2006 13:15:55 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1023.aspx</link><description>Ok I added the code like you said and it did filter the chlid records for the first record in the parent business object.  However it did not refresh the child filter upon navigation of the parent records.&lt;br&gt;
&lt;br&gt;
The ChildBO.filter property returned this value: "pub_id=0736", the first row in the ParentBO.</description><pubDate>Mon, 01 May 2006 11:59:19 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1021.aspx</link><description>OK, well that explains that... 1=0 will hide all child records.&lt;br&gt;
&lt;br&gt;
Whenever there are no records visible within the parent business object, the filter is set to that value so that it will hide the records within the child business object as well.  This is kind of a bootstrap issue, because the child records are filtered whenever the ParentBusinessObject property is set on the child business object, and that happens during the form's InitializeComponent() method, and both business objects are empty.  &lt;br&gt;
&lt;br&gt;
Add this line of code in the parent business object's ParentFormLoading event handler, right after you fill it:&lt;br&gt;
&lt;br&gt;
ParentBO.FilterChildRecords()&lt;br&gt;
&lt;br&gt;
This will go through the filter logic again, and filter the records properly.  After that, the records will be filtered automatically when the record within the parent business object is navigated.</description><pubDate>Mon, 01 May 2006 10:51:37 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1020.aspx</link><description>The ChildBO.CurrentDataTable.Rows.Count was equal to 18.&lt;br&gt;
&lt;br&gt;
The ChildBO.Count was equal to 0.&lt;br&gt;
&lt;br&gt;
The ChildBO.Filter was equal to 1=0.</description><pubDate>Mon, 01 May 2006 10:33:11 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1019.aspx</link><description>Make sure that both of your business objects' IsListSource properties are set to True.&lt;br&gt;
&lt;br&gt;
After that, Mike, you haven't forgotten anything... what you can do is this:&lt;br&gt;
&lt;br&gt;
Set a breakpoint in a button on the form so that we can check some of the values on the business objects at runtime in the Watch &amp;#119;indow. &lt;br&gt;
&lt;br&gt;
Check the ChildBO.CurrentDataTable.Rows.Count property on the child business object and make sure it's greater than 0.&lt;br&gt;
&lt;br&gt;
Check the ChildBO.Count property on the child business object and see if it's greater than 0.  This value will tell you the number of visible records within the business object while the above value will tell you the number of records, visible or not.&lt;br&gt;
&lt;br&gt;
Check the ChildBO.Filter property... it should be set to a value like this:  "my_fk='parentpkvalue'" which hides all records within the child business object that don't match the current row within the parent business object.  This value should follow the relationship you've defined on the business objects.  If it doesn't then we have a problem :)</description><pubDate>Mon, 01 May 2006 10:24:24 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost1018.aspx</link><description>Ok, I feel a little confused and am not sure why i haven't got this to work. So I am going to reiterate what I have done to this point and we'll go from there.&lt;br&gt;
&lt;br&gt;
I've created two business objects, a parent and a child. Both of these business objects are being filled through their ParentFormLoading events.  &lt;br&gt;
&lt;br&gt;
I've configured the ParentRelationship property on the child business object's class.&lt;br&gt;
&lt;br&gt;
I've set the ParentBusinessObject property on the child business object.&lt;br&gt;
&lt;br&gt;
I've set the ChildAutoFilter property on the parent business object to MatchCurrentRow.&lt;br&gt;
&lt;br&gt;
Both of the business objects are filling properly with data, but I dont see any records in the child grid.&lt;br&gt;
&lt;br&gt;
Have I forgot something? :unsure:</description><pubDate>Mon, 01 May 2006 10:16:05 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost998.aspx</link><description>Nah, don't worry about attaching the project.  This is what I did:&lt;br&gt;
&lt;br&gt;
1) Put the parent business object in DataGridView1 and the child in DataGridView2.&lt;br&gt;
2) Handled the DataGridView1.Click event with this code:&lt;br&gt;
&lt;br&gt;
Private Sub DataGridView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.Click&lt;br&gt;
        If Me.DataGridView1.SelectedRows.Count = 1 Then&lt;br&gt;
            Me.BusinessObject11.Navigate(MicroFour.StrataFrame.Business.BusinessNavigationDirection.Absolute, Me.DataGridView1.SelectedRows(0).Index)&lt;br&gt;
        ElseIf Me.DataGridView1.SelectedCells.Count = 1 Then&lt;br&gt;
            Me.BusinessObject11.Navigate(MicroFour.StrataFrame.Business.BusinessNavigationDirection.Absolute, Me.DataGridView1.SelectedCells(0).RowIndex)&lt;br&gt;
        End If&lt;br&gt;
    End Sub&lt;br&gt;
&lt;br&gt;
3) Set the ChildAutoFilterOption on the parent business object to MatchCurrentRow. &lt;br&gt;
4) Made sure that the parent business object was set as the ParentBusinessObject on the child business object.&lt;br&gt;
&lt;br&gt;
With those steps, when you click on the parent grid, it will filter the child records so that only the records within the child business object that match the currently selected parent will be visible.&lt;br&gt;
&lt;br&gt;
Now, if you want to requery the database for child records each time you click on a parent record, you'll need to add an event handler for the Navigated event on the parent business object and repopulate the child business object with the appropriate records.</description><pubDate>Fri, 28 Apr 2006 10:09:09 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost997.aspx</link><description>My sample is based on the pubs table, would it be easier for you to debug if I attached the project?</description><pubDate>Fri, 28 Apr 2006 10:02:42 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost996.aspx</link><description>What data are you pulling in?&lt;br&gt;
&lt;br&gt;
Are you pulling a set of parent records and then also pulling in all of the child records for those parent records?</description><pubDate>Fri, 28 Apr 2006 09:49:29 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost995.aspx</link><description>Ok, on one form i have two grids and i have everything setup correctly, i think, i have both grids filling with data... but when i move between rows on the parent grid the child grid isnt synching... Any ideas?</description><pubDate>Fri, 28 Apr 2006 09:35:48 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost994.aspx</link><description>If you wanted the form to show in the double-click of a row, then you would add a handler to the grid's double-click event and place the code in there.&lt;br&gt;
&lt;br&gt;
Private Sub DataGridView1_DoubleClick(ByVal sender As Object, ByVal e As EventArgs)&lt;br&gt;
    '-- Call the child form&lt;br&gt;
    Me.MyChildFormDialog.ShowDialog()&lt;br&gt;
End Sub</description><pubDate>Fri, 28 Apr 2006 08:43:28 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Tutorial 14 (Configuring a Business Object relationship)</title><link>http://forum.strataframe.net/FindPost993.aspx</link><description>Yes Trent it did help. ;) I'm getting closer. :D&lt;br&gt;
&lt;br&gt;
Ben had posted this earlier and I'm not sure what he meant by this:&lt;br&gt;
&lt;br&gt;
[quote]4) Within code, call ChildFormDialog.ShowDialog() to show the child form. The business objects configured in the BusinessObjectTranslations will be translated so that the instances on the main form are the same instances that are on the child form.[/quote]&lt;br&gt;
&lt;br&gt;
Where within code am I supposed to put the ShowDialog line?  What if i wanted the child form to pop-up on double click of a row?</description><pubDate>Fri, 28 Apr 2006 08:24:24 GMT</pubDate><dc:creator>StarkMike</dc:creator></item></channel></rss>