StrataFrame Forum

ChildForm with a ListView

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

By Juan Carlos Pazos - 1/21/2009

Hi

I have a form with a parent BO and several child BO's, in the main form I use several Listview's and child forms to handle tha data and works pretty well, click on the Edit and the ChildForm shows and let me edit the record.

But I need to open a Child that shows a list of records (ListView) not only one record like all other child's. This ChildForm of course is a related to the main form and should shows the records related to the record selected in the main. I follow the same logic that the other children, establish the relationship and open the form, but How should I fill the data in the list?

The scenario is this, the main form is a Products form, the child form will be open if the product is a kit, so the child windows should have a list with products that are part of the kit, so in this form I have a New, Edit and Delete buttons. The problem is how should the ListView PopulationDataSourceSettings shoud go?

Thanks for your help

By Edhy Rijo - 1/21/2009

Hi Juan,

Let me see if I understand your situation here:

You need to show items in the ListView for Products that are flagged as Kit, right?

If so you need to do the following in the ListView:

  1. Set the Listview1.PopulateOnFormLoad = Manual
  2. Set the Listview1.PopulateDataSourceSettings to CopyDataFrom(BusinessLayerBase,BusinessCloneDataType)
  3. In the ListPopulating event, set the Parameters as follow:

e.Parameters(0).Value = Me.ProductsBO

e.Parameters(1).Value = MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromDefaultView

Now in the ProductsBO.Navigated event put code to filter the listview data and requery the ListView as needed, something like this:

If Me.ProductsBO.Count > 0 Then

'-- Filter all the order items for the current Order PK

Me.ChildBO.Filter = "KitFlag=" & Me.ChildBO.KitFlag.ToString

End If

' Force the ListView to Requery to Enable/Disable its toolbar

Me.ListView1.Requery()

This is just one approach to give you an idea, of course if the child BO may have a lot of record for the same parent, then instead of using the CopyDataFrom method in the PopulateDataSourceSettings you can create a method in your ChildBO with a parameter to get the data related to the parent with the KitFlag value, and you set those values as parameters in the ListPopulating Event.