473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 1256
* "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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: Benno Bös | last post by:
If I use the following construct in the frame "main" for a link to an extern site: <A HREF="http://www.any.xy" TARGET="extern"> the Browser is creating the window "extern", loading the page...
10
by: Tom Szabo | last post by:
Is there an event when that triggers when the window is closing.... I am talking about when the user clicks on the cross on the right top corner of the window!!!
4
by: Peter Pagé | last post by:
Hi, I've got a window with a "<body onBlur="window.close()"> tag that keeps closing prematurely. It happens when the user clicks on text inside a table in the same window. Apparently IE...
3
by: ThunderMusic | last post by:
Hi, I'm trying to have a MSN Messenger like form/app closing behavior. When I click on the X button, I only want the form to disappear and when I double-click on the notify icon or right-click...
3
by: Saradhi | last post by:
Hi, I wanted to stop the VS.NET Window from closing inside my C# AddIn. I Know that OnBeginShutdown() funciton will be called whenever the user tries to close the VS.NET window. I want to...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
2
by: Tom | last post by:
How is the best way to avoid validation when closing a window? For instance, I have a Windows Forms window which has a validation event for a text box. However, if one enters invalid data in then...
3
by: bilosta | last post by:
Hello to everybody I'm new in win apllications and C#. I have a problem with Threading. Here is my problem: I have a form with button named: BupisiStudente, when I click on it a call next...
37
by: Jan Tovgaard | last post by:
Hey everyone:) We have a critical problem, which I can see that other people also has ran into. In Internet Explorer 7 it is no longer possible to do a window.close after opening a window,...
2
by: javanet | last post by:
Hi all, 1) i opened a parent window. 2) then i opend a child window thruogh this parent window. Now i want to close child window before closing the parend window means my clients can not be...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.