StrataFrame Forum

Business Objects - User Controls

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

By Tim Dol - 6/29/2007

Trent helped me out a month or so ago with Business Objects and User Controls and things are working fine but I have came accross another issue which I can't seem to resolve.  Here is my scenerio

I have a 'Contact' user control that contains a Grid, Contact Business Object and Business Binding Source. I drop the same Contact BO on my form along with my Contact User control and set the BO Translation property.  I populate the Contact BO on my form and set the Usercontrol's bbs.businessOject =  my forms Contact BO.  THis works fine thanks to Trent.

Now that I have a list of contacts I need the ability to edit contact infomation, without using a child dialog control, so I created a child form to edit contact information.  Now how do I translate the BO from my user control to my dialog form and keep the business objects in sync. I tried setting up a manual business object translation between the two but couldn't figure out how to populate the BO on the dialog form.

Thanks

Tim

By StrataFrame Team - 7/2/2007

You should be able to drop the ChildFormDialog on the UserControl itself (in it's designer) and call it's ShowDialog from the form like this:

Me.userControl1.childFormDialog1.ShowDialog()

When you drop it on the UserControl, you should be able to set the translations between the user control and the child form dialog.

By Tim Dol - 7/3/2007

I tried that.

When you drop a ChildFormDialog on a SF user control you receive an error message 'Invalid FrameWork Container, the object that the ChildFormDialog has been dropped on is not a subclass of MicroFour.StrataFrame.UI.Windows.Forms.BaseForm'. 

Tim

By Paul Chase - 7/5/2007

Tim,

I had the same issue you just need to forget about drag and drop and set it in code. Here is code out of my contacts user control that I use to pop up a maint form for additional editing. Anyways hope it helps

P 

Private WithEvents ChildFormDialog As MicroFour.StrataFrame.UI.Windows.Forms.ChildFormDialog

Private Sub ContactUserControl_ParentFormLoading() Handles Me.ParentFormLoading

Me.ChildFormDialog = New MicroFour.StrataFrame.UI.Windows.Forms.ChildFormDialog

Dim TranslationItem As New MicroFour.StrataFrame.UI.Windows.Forms.BusinessObjectTranslationItem

'-Configure Translation

TranslationItem.DestinationBusinessObject = "FrmAddress._BoContacts1"

TranslationItem.SourceBusinessObject = Me.BOTranslations(0).SourceBusinessObject

'-Add to Child Form Dialog

Me.ChildFormDialog.BusinessObjectTranslations.AddRange(New MicroFour.StrataFrame.UI.Windows.Forms.BusinessObjectTranslationItem() {TranslationItem})

Me.ChildFormDialog.ChildForm = "ActionLabor.Payroll.UI.Forms.FrmContactMaintenance"

Me.ChildFormDialog.ParentForm = Me.ParentForm

 

''' <summary>

''' Handles the Maintenance Button Clicked Event from The ToolBar

''' </summary>

''' <remarks></remarks>

Private Sub MaintBtnClicked()

If Not Me.ChildFormDialog Is Nothing Then

Me.ChildFormDialog.ShowDialog()

End If

End Sub