By S. Brandon Keller - 6/5/2009
Hi all,
I am just getting started with StrataFrame, so I suspect that I'm just missing something straightforward; if someone can point that out, I'd sure appreciate it.
I have a main form with a ListView and a BusinessObject which controls the data displayed. I placed an Edit button on the form, and hooked that to the EditObject property on the ListView. I then added a ChildFormDialog and set the translation to allow users to edit the values in the ListView. I am using the MessageItems.CopyDataFrom(...) method to get the data into the ListView and then to the ChildForm.
Everything is working well; the ChildForm is in edit mode when opened, and the BO is marked as dirty, as I would expect. I can Save, Undo, and Edit with the toolstrip, and everything works just fine. However, if I close the ChildForm with edits pending, and then click 'No' on the 'Save Changes' dialog, the BO in the main form remains dirty. I had expected that clicking 'No' on the 'Save Changes' dialog would trigger the Undo action, but hooking into the event for that has confirmed that the business object Undo is not being called. When the form closes, even after denying the save, the BO is dirty and still in edit mode.
Am I missng something simple?
Thanks!
|
By Edhy Rijo - 6/5/2009
Hi Brandon,
And welcome to the forums.
S. Brandon Keller (06/05/2009) Am I missng something simple?
In your child form set the property AutoShowSaveChangesMessage = False, this will allow you to go back to your parent form and handle the Save/Edit/Undo there.
I am a big fan of the SF ListView control and I would suggest you take the time to study the StrataFlix sample application which make a good use of listview with different sources. Also in your childform you can check from any broken rules before going back to the parent form, here is some sample code from one of my child forms for the Ok and Cancel buttons:
Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
'-- This code uses' the form's PrimaryBusiness Object instance to check the validations.
If Me.PrimaryBusinessObject.CheckRules(True) Then
DialogResult = Windows.Forms.DialogResult.OK
Else
'-- Show a custom InfoBox to alert the end user of the broken rules.
Dim CountOfBrokenRulesCurrentRow As Integer = Me.PrimaryBusinessObject.BrokenRules.Count
Dim CountOfBrokenRulesAdditionalRows As Integer = 0
Dim CountOfBrokenRulesTotal As Integer = Me.PrimaryBusinessObject.BrokenRules.Count
MicroFour.StrataFrame.Messaging.InfoBox.ErrorBox(MicroFour.StrataFrame.UI.Localization.RetrieveTextValue(Me.BrokenRulesAlertTitleKey, Me.BrokenRulesAlertTitle), String.Format(MicroFour.StrataFrame.UI.Localization.RetrieveTextValue(Me.BrokenRulesAlertTextKey, Me.BrokenRulesAlertText), CountOfBrokenRulesCurrentRow, CountOfBrokenRulesAdditionalRows, CountOfBrokenRulesTotal), Me)
End If
End Sub
Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
DialogResult = Windows.Forms.DialogResult.Cancel
End Sub
|
By S. Brandon Keller - 6/5/2009
Hi Edhy,
Thanks for the response. I'll dig through the StrataFlix sample and see if I can find anything that points the way. I had noticed the AutoShowSaveChangesMessage option and it's been mentioned in forum posts before, but I actually don't want to handle the events on the main form; it's for display only. My ideal scenario is that the ChildForm would handle the data events, but leave the BO in a clean state when finished - either the user saved the changes, explicitly hit 'Undo' before closing the dialog, or hit 'No' on the save confirmation prompt when closing the dialog.
|
|