By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,285 Members | 1,691 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,285 IT Pros & Developers. It's quick & easy.

Problem in Window Closing

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
* "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

P: n/a

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

P: n/a
* "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

P: n/a
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.