Public Class ABusinessForm Inherits OakLeaf.MM.Main.Windows.Forms.mmBusinessForm Public Shadows Sub NavigateData(ByVal navPosition As mmNavigate, Optional ByVal raiseEvents As Boolean = False) ... End SubThis didn't quite work for me. At the points in my form where I called NavigateData() the shadow subroutine above was called. However when I click the toolbar navigation buttons on the main form it calls the original code in mmBusinessForm.
Protected Overloads Overrides Function HookPreCancel(ByVal bizObj As OakLeaf.MM.Main.Business.mmBusinessObject, ByVal tableName As String) As Boolean Me.IgnoreIsChanged = True Return MyBase.HookPreCancel(bizObj, tableName) End Function Protected Overloads Overrides Function HookPreDelete(ByVal drView As System.Data.DataRowView) As Boolean Me.IgnoreIsChanged = True Return MyBase.HookPreDelete(drView) End Function So now the bottom of HookPreNavigate() looks like this: Dim RetVal As Boolean = True Dim FocusOnSaveControl As Control Dim FocusOnCancelControl As Control Dim IgnoreIsChanged As Boolean = Me.IgnoreIsChanged If Me.IgnoreIsChanged Then Me.IgnoreIsChanged = False End If If Me.PrimaryBizObj.IsChanged Then If Not IgnoreIsChanged Then FocusOnSaveControl = Me.FocusOnSaveControl Me.FocusOnSaveControl = Nothing FocusOnCancelControl = Me.FocusOnCancelControl Me.FocusOnCancelControl = Nothing If AskSaveChanges(Me.PrimaryBizObj) = DialogResult.Cancel Then RetVal = False End If Me.FocusOnSaveControl = FocusOnSaveControl Me.FocusOnCancelControl = FocusOnCancelControl End If End If Return RetVal And MyBase.HookPreNavigate()This cures everything except btnNew. When btnNew is clicked it eventually executes:
Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click If Me.btnNew.Result Then ' Ignore the IsChanged property in ABusinessForm.NavigateData Me.IgnoreIsChanged = True ' Navigate to the new record Me.NavigateData(mmNavigate.Last, True) End If End SubNotice that I have to do Me.IgnoreIsChanged = True because I am sitting on the new record which has primary key = -1 and is therefore changed. I feel like I'm writing kluge code here. How can this be cleaned up in the framework?