Hi Trent,I have the following code in the combo...
Private Sub cboPolicySymbol_ListPopulating(ByVal e As MicroFour.StrataFrame.UI.ListPopulatingEventArgs) Handles cboPolicySymbol.ListPopulating e.Parameters(0).Value =
Me.PolicyBO1.FK_InsuranceCompanyEnd Sub I am populating the combo with a method I created in the BO:
Public Sub FillPolicySymbolsByInsuranceCompany(ByVal InsuranceCompanyPrimaryKey As Int32) Using cmd As New SqlCommand() cmd.CommandText =
String.Format("SELECT * FROM {0} WHERE FK_InsuranceCompany = " & InsuranceCompanyPrimaryKey.ToString(), Me.TableName) Me.FillDataTable(cmd) End UsingEnd Sub This is working fine, except when I add a new record and instead of saving I cancel it with the following code:
Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click '-- Remove all Payments Schedule only when adding a new policy and this is cancelled. If Me.PolicyBO1.EditingState = MicroFour.StrataFrame.Business.BusinessEditingState.Adding Then DeleteAllPaymentSchedule()
End If Me.PolicyBO1.Undo(MicroFour.StrataFrame.Business.BusinessUndoType.CurrentRowOnly) Me.PaymentScheduleBO1.Undo(MicroFour.StrataFrame.Business.BusinessUndoType.AllRows) Me.DialogResult = Windows.Forms.DialogResult.CancelEnd Sub I get the following error:
BusinessLayerException
The CurrentRow could not be evaluated because the CurrentRowIndex is out of range. Business object record count: 0. CurrentRowIndex: -1.
Source : MicroFour StrataFrame Business
Stack Trace:
at MicroFour.StrataFrame.Business.BusinessLayer.get_CurrentRow()
at IBS_BOL.PolicyBO.get_FK_InsuranceCompany() in E:\Visual Studio 2008 Projects\StrataFrame\Insurance Broker System (SF)\BOL\IBS_BOL\Main Forms BOs\PolicyBO.Designer.vb:line 358
at IBS_UI.frmPolicy.cboPolicySymbol_ListPopulating(ListPopulatingEventArgs e) in E:\Visual Studio 2008 Projects\StrataFrame\Insurance Broker System (SF)\UI\Main Forms\frmPolicy.vb:line 176
at MicroFour.StrataFrame.UI.Windows.Forms.ComboBox.RaiseListPopulatingEvent(ListPopulatingEventArgs e)
at MicroFour.StrataFrame.UI.Windows.Forms.ListControl.PopulateComboFromBusinessObject(IListControl lstControl, Object[] Parameters)
at MicroFour.StrataFrame.UI.Windows.Forms.ListControl.PopulateCombo(Control lstControl, Object[] Parameters)
at MicroFour.StrataFrame.UI.Windows.Forms.ComboBox.PopulateCombo(Object[] Parameters)
at MicroFour.StrataFrame.UI.Windows.Forms.ComboBox.Requery()
at IBS_UI.frmPolicy.PolicyBO1_Navigated(NavigatedEventArgs e) in E:\Visual Studio 2008 Projects\StrataFrame\Insurance Broker System (SF)\UI\Main Forms\frmPolicy.vb:line 165
at MicroFour.StrataFrame.Business.BusinessLayer.NavigatedEventHandler.Invoke(NavigatedEventArgs e)
at MicroFour.StrataFrame.Business.BusinessLayer.raise_Navigated(NavigatedEventArgs e)
at MicroFour.StrataFrame.Business.BusinessLayer.OnNavigated(NavigatedEventArgs e)
at MicroFour.StrataFrame.Business.BusinessLayer.Navigate(BusinessNavigationDirection Direction, Int32 AbsoluteIndex, Object[] PrimaryKeyValues, Boolean AttemptToCheckRules, Boolean IsRefill)
at MicroFour.StrataFrame.Business.BusinessLayer.RestoreCurrentRowIndex(Boolean RefreshUI)
at MicroFour.StrataFrame.Business.BusinessLayer.Undo(BusinessUndoType UndoType)
at IBS_UI.frmPolicy.cmdCancel_Click(Object sender, EventArgs e) in E:\Visual Studio 2008 Projects\StrataFrame\Insurance Broker System (SF)\UI\Main Forms\frmPolicy.vb:line 106
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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)
If I replace the ComboBox Listpopulating with this code, it will fix the error, but I am not sure if this is something I should do with all my ComboBoxes ListPopulating event parameters....
Private Sub cboPolicySymbol_ListPopulating(ByVal e As MicroFour.StrataFrame.UI.ListPopulatingEventArgs) Handles cboPolicySymbol.ListPopulating If Me.PolicyBO1.CurrentRowIndex = -1 Then e.Parameters(0).Value = 0
Else e.Parameters(0).Value =
Me.PolicyBO1.FK_InsuranceCompany End IfEnd Sub P.S.
Sorry for the long post, but it was needed.