Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detecting changes in children
Message
 
To
19/10/2004 18:12:59
Max Fillmore
Essential Skills, Inc.
Lenexa, Kansas, United States
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
00951764
Message ID:
00953201
Views:
26
Max,

>
> 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 Sub
>
>This 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.

That's because you used the Shadows keyword...you should use the Overrides keyword instead. "Shadows" is used to create a brand new implemetation of a method that breaks the inheritance chain.


>Notice 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?

I've added an extra check at the top of the code for the value of raiseEvents and navPosition...see if that helps:
    Public Overrides Sub NavigateData(ByVal navPosition As mmNavigate, ByVal raiseEvents As Boolean)
        If raiseEvents AndAlso (navPosition <> mmNavigate.Refresh And navPosition <> mmNavigate.Update) Then

            If Not (Me.ActiveControl Is Nothing) Then
                ' Make sure the current UI control value is written back to the data
                Dim grid As mmDataGrid = CType(Me.ActiveControl.Parent, mmDataGrid)

                grid.EndEdit(Nothing, grid.CurrentRowIndex, False)

                If TypeOf grid.DataSource Is DataSet Then
                    Dim ds As DataSet = CType(grid.DataSource, DataSet)
                    ' Determine the table name
                    Dim TableName As String = Nothing
                    Dim ViewName As String = Nothing

                    Dim BizObj As mmBusinessObject = CType(mmAppDesktop.FormMgr.GetControlBizObj(grid), 
mmBusinessObject)
                    If Not (BizObj Is Nothing) Then
                        mmBindingStrategyBase.GetBindingSource(BizObj, grid.BindingSourceMember, 
TableName, ViewName)
                    End If
                    If Not mmString.Empty(TableName) Then
                        ds.Tables(TableName).Rows(grid.CurrentRowIndex).EndEdit()
                    Else
                        ds.Tables(0).Rows(grid.CurrentRowIndex).EndEdit()
                    End If
                Else
                    If TypeOf grid.DataSource Is DataView Then
                        Dim dv As DataView = CType(grid.DataSource, DataView)
                        dv.Table.Rows(grid.CurrentRowIndex).EndEdit()
                    End If
                End If
            Else
                Dim cntrl As Control = CType(Me.ActiveControl, Control)
                If cntrl.DataBindings.Count > 0 Then
                    Me.BindingContext(cntrl.DataBindings(0).DataSource).EndCurrentEdit()
                End If
            End If

            ' Check for changes
            If Me.IsChanged() Then
                Dim CancelControl As Control = Me.FocusOnCancelControl
                Dim SaveControl As Control = Me.FocusOnSaveControl
                Me.FocusOnCancelControl = Nothing
                Me.FocusOnSaveControl = Nothing

                ' Ask the user if they want to save changes
                Dim result As DialogResult = Me.AskSaveChanges()

                Me.FocusOnCancelControl = CancelControl
                Me.FocusOnSaveControl = SaveControl

                If result = DialogResult.Cancel Then
                    Return
                End If
            End If
        End If
        MyBase.NavigateData(navPosition, raiseEvents)
    End Sub
Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform