472,119 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

Problem in Window Closing

Hi All,
In Winform Application, MDI form is having Save button.
When i close the application, it will ask Save Changes?
YES or NO or CANCEL.
after i select CANCEL button, i have set e.Cancel = True
So application will work continously,
But Save button Event is working.
Can anybody give me the solution for this situation?

Regards,
Amal
Nov 20 '05 #1
4 1192
* "Amalorpavanathan Y \(Amal\)" <am*********@lycos.com> scripsit:
In Winform Application, MDI form is having Save button.
When i close the application, it will ask Save Changes?
YES or NO or CANCEL.
after i select CANCEL button, i have set e.Cancel = True
So application will work continously,
But Save button Event is working.
Can anybody give me the solution for this situation?


"Post code."

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2

Private Sub TEST_Closing(ByVal sender As Object, ByVal
e As System.ComponentModel.CancelEventArgs) Handles
MyBase.Closing
If Me.gdstTEST.HasChanges() Then
Select Case (MessageBox.Show(" Do you want to
save the changes that you made ", "Test",
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button1))
Case DialogResult.Yes
Me.DoSave()
Case DialogResult.No
Me.gdstTEST.RejectChanges()
Me.Close()
Case DialogResult.Cancel
e.Cancel = True
End Select
End If
End Sub
-----Original Message-----
* "Amalorpavanathan Y \(Amal\)" <am*********@lycos.com>

scripsit:
In Winform Application, MDI form is having Save button.
When i close the application, it will ask Save Changes?
YES or NO or CANCEL.
after i select CANCEL button, i have set e.Cancel = True
So application will work continously,
But Save button Event is working.
Can anybody give me the solution for this situation?


"Post code."

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
.

Nov 20 '05 #3
* "Amalorpavanathan Y \(AMAL\)" <am*********@lycos.com> scripsit:
Private Sub TEST_Closing(ByVal sender As Object, ByVal
e As System.ComponentModel.CancelEventArgs) Handles
MyBase.Closing
If Me.gdstTEST.HasChanges() Then
Select Case (MessageBox.Show(" Do you want to
save the changes that you made ", "Test",
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button1))
Case DialogResult.Yes
Me.DoSave()
Case DialogResult.No
Me.gdstTEST.RejectChanges()
Me.Close()
Case DialogResult.Cancel
e.Cancel = True
End Select
End If
End Sub


And where is the "Save" button?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Hi Herfried,

Sorry, Thank you for your immediate reponse.
i have solved this problem,

Please see the save event below

(MDI form save button in toolbar)
when i click the save button, event flow like

step 1:

Private Sub TEST_Closing(ByVal sender As Object, ByVal
e As System.ComponentModel.CancelEventArgs) Handles
MyBase.Closing
If Me.gdstTEST.HasChanges() Then
Select Case (MessageBox.Show(" Do you want to
save the changes that you made ", "Test",
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button1))
Case DialogResult.Yes
Me.DoSave()
Case DialogResult.No
Me.gdstTEST.RejectChanges()
Me.Close()
Case DialogResult.Cancel
e.Cancel = True
End Select
End If
End Sub

step 2:

Public Sub UnhookAllActions() Implements
IToolbarActionManager.UnhookAllActions
saveAction = Nothing
deleteAction = Nothing
clearAction = Nothing
End Sub

step 3:
Private saveAction As Core.ToolbarAction
Private deleteAction As Core.ToolbarAction
Private clearAction As Core.ToolbarAction

Private Sub ToolBar_ButtonClick(ByVal sender As
System.Object, ByVal e As
System.Windows.Forms.ToolBarButtonClickEventArgs) Handles
ToolBar.ButtonClick
If e.Button.Text = "Save" And Not saveAction Is
Nothing Then
saveAction()
ElseIf e.Button.Text = "Clear" And Not clearAction
Is Nothing Then
clearAction()
ElseIf e.Button.Text = "Delete" And Not
deleteAction Is Nothing Then
deleteAction()
End If
End Sub

when i click the save button, saveAction will be maked
as nothing,
So the event has not been worked. i resolved this problem.

Thank you
-----Original Message-----
* "Amalorpavanathan Y \(AMAL\)" <am*********@lycos.com>

scripsit:
Private Sub TEST_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles
MyBase.Closing
If Me.gdstTEST.HasChanges() Then
Select Case (MessageBox.Show(" Do you want to save the changes that you made ", "Test",
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning,
MessageBoxDefaultButton.Button1))
Case DialogResult.Yes
Me.DoSave()
Case DialogResult.No
Me.gdstTEST.RejectChanges()
Me.Close()
Case DialogResult.Cancel
e.Cancel = True
End Select
End If
End Sub


And where is the "Save" button?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
.


Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

31 posts views Thread by Benno Bs | last post: by
3 posts views Thread by Saradhi | last post: by
3 posts views Thread by bilosta | last post: by
37 posts views Thread by Jan Tovgaard | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.