StrataFrame Forum

Close form and ask for save

http://forum.strataframe.net/Topic8180.aspx

By Chan - 4/17/2007

Hi,

Any built in method that I can call to close a form which will ask for save if datatable is dirty?

Thank you

By Trent L. Taylor - 4/17/2007

The StrataFrame baseform already does this when a BO which is dropped on this form is dirty.  By default this functionality already exists.  You have to set the forms AutoAskSaveChanges property to False to prevent this type of functionality.
By Chan - 4/18/2007

Hi,

I have set the "AutoAskSaveChanges" property to true. It works when I close the form interactively. How could to have the same "behavor" if I want to close the form programmatically? Currently, I tried to form.Dispose(), the form just released without and prompt.

Please advice

Thank you

By Trent L. Taylor - 4/18/2007

This is handled in the FOrmClosing event of the form, so anything that logically attempts to close the form should trigger the message.  For example:

Me.Close()
By Chan - 4/19/2007

Hi.

How could I know the form is really closed? User may select "cancel" in ask for save dialog.

Thank you

By Trent L. Taylor - 4/19/2007

Handle the FormClosed event.  This want you know for sure that the form has been closed.
By Chan - 4/19/2007

Hi,

What I am doing is to interate all forms, close them and launch connection dialog. Therefore, i couldn't handle formclosing event.

By Trent L. Taylor - 4/19/2007

You could if you iterate through all of the forms and add a handler that references a single method:

Dim loForm As Form

For Each loForm In MyFormsCollection
    AddHandler loForm.FormClosing, Addressof YourFormClosingMethod
Next

You could then place your code in the "YourFormClosingMethod" to check on whatever you needed.

By Fabian R Silva, - - 9/4/2007

Trent L. Taylor (04/17/2007)
The StrataFrame baseform already does this when a BO which is dropped on this form is dirty. By default this functionality already exists. You have to set the forms AutoAskSaveChanges property to False to prevent this type of functionality.




I have a "menu" form (it have a Business object to populate a treeview)

When I close the applicaction, it show the save dialog can I avoid this to happen on that form? thanks!
By Fabian R Silva, - - 9/4/2007

Note about the last post: I only fill a Business object (but not edit any property of them... only filter it sometimes) and fill a treeview with that data



I set on the form:

Me.myBO1.IncludeInFormSave = False

Me.IncludeInFormSaveType = MicroFour.StrataFrame.Business.IncludeInFormTypeOptions.DeterminedByBusinessObject



if I set

Me.AutoShowSaveChangesMessage = False or me.myBo1.clear() and close the form, this not say if I like to save



me.MenuesBO1.IsDirty = true when I test it after the fill method



What I made wrong? thanks!
By Greg McGuffey - 9/4/2007

Are you expecting the BO on the menu form to be dirty? Did you manipulate it or the CurrentDataTable? If so, you could just either save it or undo the changes, to save or loose those changes, programmatically. Do this in the FormClosing event (I pretty sure Ermm ).



Or you could just set the AutoAskSaveChanges property on the form to not prompt to save the changes. I'm guessing that it would either just always save or always undo or that you can set what it does if you don't ask to save changes.
By Fabian R Silva, - - 9/5/2007

Greg McGuffey (09/04/2007)
Are you expecting the BO on the menu form to be dirty? Did you manipulate it or the CurrentDataTable? If so, you could just either save it or undo the changes, to save or loose those changes, programmatically. Do this in the FormClosing event (I pretty sure Ermm ).



Or you could just set the AutoAskSaveChanges property on the form to not prompt to save the changes. I'm guessing that it would either just always save or always undo or that you can set what it does if you don't ask to save changes.




You're right, I not see before that I edit the currentDataTable and add a new column next to the fill method on the business object Blush



Question:

I can´t find the AutoAskSaveChanges property on the form, not in designer, not via "me.AutoAskSaveChanges = false", where I can find this?



Thanks for you reply



- Fabian
By Trent L. Taylor - 9/5/2007

where I can find this?

This is a property on the form.  If you created a standard .NET form and are not using the SF Standard form or inheriting from the SF BaseForm, you will not have this property....and you will have some other problems down the road as it relates to "normal" functionality.  If you select the form in the designer and go to the property sheet, you should see this property.

By Fabian R Silva, - - 9/5/2007

Trent L. Taylor (09/05/2007)
where I can find this?





This is a property on the form. If you created a standard .NET form and are not using the SF Standard form or inheriting from the SF BaseForm, you will not have this property....and you will have some other problems down the road as it relates to "normal" functionality. If you select the form in the designer and go to the property sheet, you should see this property.







Sorry I not thinked that AutoAskSaveChanges = AutoShowSaveChangesMessage, I utilized AutoShowSaveChangesMessage on my tests but I supposed that AutoAskSaveChanges have another purpose or something else w00t woops



again I have to say thanks for your great response and sorry for my mistake Smile



- Fabian


By StrataFrame Team - 9/6/2007

No problem.  All of the automation on the form can be both customized to show a different message or turned off completely.  You just have to fish around until you find the property that does what you want it to.  Sometimes the descriptions of the properties help, too (if you can see the description at the bottom of the property sheet, sometimes it's hidden).