Hi,
I created an composite model class that host my parent and childs BO. I event bind them as suggested. But hit error as below.

If I set my child BO as form's PrimarkBusinessObject, it works fine.
using System;
using System.Collections.Generic;
using System.Text;
using JK.Inventory.BusinessObject.Main;
using MicroFour.StrataFrame.Business;
using MicroFour.StrataFrame.Data;
namespace JK.Inventory.BusinessObject.Composite
{
public class CompaniesBOModel
{
#region "Private Fields"
private CompaniesBO _CompaniesBO;
private CompanyAddressBO _CompanyAddressBO;
private CompanyContactsBO _CompanyContactsBO;
#endregion "Private Fields"
#region "Constructor"
public CompaniesBOModel() :base()
{
}
public CompaniesBOModel(CompaniesBO toCompanyBO, CompanyAddressBO toCompanyAddressBO,
CompanyContactsBO toCompanyContactBO)
{
this._CompaniesBO = toCompanyBO;
this._CompanyAddressBO = toCompanyAddressBO;
this._CompanyContactsBO = toCompanyContactBO;
this._CompanyAddressBO.ParentBusinessObject = this._CompaniesBO;
this._CompanyContactsBO.ParentBusinessObject = this._CompaniesBO;
this._CompaniesBO.ChildAutoFilterOption = AutoChildFilterOptions.MatchCurrentRow;
this.BindBOEventHandler();
}
#endregion "Constructor"
#region "Methods"
private void BindBOEventHandler()
{
this._CompaniesBO.AfterAddNew += new CompaniesBO.AfterAddNewEventHandler(this.AfterCompaniesBOAddNewEventHandler);
this._CompaniesBO.AfterDelete += new CompaniesBO.AfterDeleteEventHandler(this.AfterCompaniesBODeleteEventHandler);
this._CompaniesBO.AfterSave += new CompaniesBO.AfterSaveEventHandler(this.AfterCompaniesBOSaveEventHandler);
this._CompaniesBO.AfterUndo += new CompaniesBO.AfterUndoEventHandler(this.AfterCompaniesBOUndoEventHandler);
this._CompaniesBO.EditingStateChanged += new CompaniesBO.EditingStateChangedEventHandler(this.CompaniesBOEditingStateChangedEventHandler);
}
#endregion "Methods"
#region "Event Handler"
private void AfterCompaniesBOAddNewEventHandler(EventArgs e)
{
//this._CompanyAddressBO.Add();
this._CompanyContactsBO.Add();
}
private void AfterCompaniesBOSaveEventHandler(AfterSaveUndoEventArgs e)
{
this._CompanyAddressBO.Save();
this._CompanyContactsBO.Save();
}
private void AfterCompaniesBOUndoEventHandler(AfterSaveUndoEventArgs e)
{
this._CompanyAddressBO.Undo(BusinessUndoType.AllRows);
this._CompanyContactsBO.Undo(BusinessUndoType.AllRows);
}
private void AfterCompaniesBODeleteEventHandler(AfterDeleteEventArgs e)
{
}
private void CompaniesBOEditingStateChangedEventHandler(EditingStateChangedEventArgs e)
{
if (e.EditingState == BusinessEditingState.Editing)
{
this._CompanyAddressBO.Edit();
this._CompanyContactsBO.Edit();
}
}
#endregion "Event Handler"
#region "Properties"
public CompaniesBO CompaniesBO
{
get
{
return this._CompaniesBO;
}
}
public CompanyAddressBO CompanyAddressBO
{
get
{
return this._CompanyAddressBO;
}
}
public CompanyContactsBO CompanyContactsBO
{
get
{
return this._CompanyContactsBO;
}
}
#endregion "Properties"
}
}
System.IndexOutOfRangeException was unhandled by user code
Message="Index 0 is either negative or above rows count."
Source="System.Data"
StackTrace:
at System.Data.DataView.GetElement(Int32 index)
at System.Data.DataView.get_Item(Int32 recordIndex)
at MicroFour.StrataFrame.Business.BusinessLayer.get_CurrentRow()
at JK.Inventory.BusinessObject.Main.CompanyContactsBO.set_ContactTypeID(ContactType value) in F:\Projects\Inventory\InventoryBusinessObject\Main\CompanyContactsBO.Designer.cs:line 306
at JK.Inventory.BusinessObject.Main.CompanyContactsBO.CompanyContacts_SetDefaultValues() in F:\Projects\Inventory\InventoryBusinessObject\Main\CompanyContactsBO.cs:line 76
at MicroFour.StrataFrame.Business.BusinessLayer.raise_SetDefaultValues()
at MicroFour.StrataFrame.Business.BusinessLayer.OnSetDefaultValues()
at MicroFour.StrataFrame.Business.BusinessLayer.NewRow()
at MicroFour.StrataFrame.Business.BusinessLayer.Add(Boolean CheckSecurity)
at MicroFour.StrataFrame.Business.BusinessLayer.Add()
at JK.Inventory.BusinessObject.Composite.CompaniesBOModel.AfterCompaniesBOAddNewEventHandler(EventArgs e) in F:\Projects\Inventory\InventoryBusinessObject\Composite\CompanyBOModel.cs:line 62
at MicroFour.StrataFrame.Business.BusinessLayer.raise_AfterAddNew(EventArgs e)
at MicroFour.StrataFrame.Business.BusinessLayer.OnAfterAddNew(EventArgs e)
at MicroFour.StrataFrame.Business.BusinessLayer.NewRow()
at MicroFour.StrataFrame.Business.BusinessLayer.Add(Boolean CheckSecurity)
at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Add(Boolean CheckSecurity)
at MicroFour.StrataFrame.UI.Windows.Forms.MaintenanceFormToolStrip.cmdNew_Click(Object sender, EventArgs e)
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)