473,387 Members | 1,540 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,387 software developers and data experts.

Cancel form close

Hello there
IS there a way to cancel a form close after the user clicks on the close
button?
I want to confirm from the user the close operation and if he chooses not
to, I would cancel the operation
any ideas?
Regards
Sameh
Nov 21 '05 #1
3 12511
Hi,

**
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Dim dlgres As DialogResult = _
MessageBox.Show("Are you shure you want to close this
widnow?", _
"MyApp", _
MessageBoxButtons.YesNo, _
MessageBoxIcon.Question)
If dlgres = DialogResult.No Then
e.Cancel = True
End If
End Sub
**

Regards,
Josip Habjan
URL: http://www.habjansoftware.com

"Sameh Ahmed" <es******@hotmail.com> wrote in message
news:uH**************@TK2MSFTNGP10.phx.gbl...
Hello there
IS there a way to cancel a form close after the user clicks on the close
button?
I want to confirm from the user the close operation and if he chooses not
to, I would cancel the operation
any ideas?
Regards
Sameh

Nov 21 '05 #2
thanks so much
e.Cancel = True
this is the part I was looking for

"Josip Habjan" <jh*****@SPAM-OFF.net.hr> wrote in message
news:d9**********@magcargo.vodatel.hr...
Hi,

**
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Dim dlgres As DialogResult = _
MessageBox.Show("Are you shure you want to close this
widnow?", _
"MyApp", _
MessageBoxButtons.YesNo, _
MessageBoxIcon.Question)
If dlgres = DialogResult.No Then
e.Cancel = True
End If
End Sub
**

Regards,
Josip Habjan
URL: http://www.habjansoftware.com

"Sameh Ahmed" <es******@hotmail.com> wrote in message
news:uH**************@TK2MSFTNGP10.phx.gbl...
Hello there
IS there a way to cancel a form close after the user clicks on the close
button?
I want to confirm from the user the close operation and if he chooses not
to, I would cancel the operation
any ideas?
Regards
Sameh


Nov 21 '05 #3
"Sameh Ahmed" <es******@hotmail.com> schrieb
Hello there
IS there a way to cancel a form close after the user clicks on the
close button?
I want to confirm from the user the close operation and if he
chooses not to, I would cancel the operation
any ideas?
Regards
Sameh

Catch the Closing event.

Armin
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ron L | last post by:
I have an MDI application which opens a number of child windows, each of which could have data in a state that needs to be saved. Each child window catches its Closing event and cancels it if the...
0
by: bj7lewis | last post by:
I have two modal dlg forms that are invoked(seperately) by a main form but the two modal dlg forms don't close when clicking the OK & Cancel buttons setup as below... Here the setup... //In...
13
by: Mike L | last post by:
I have a child form frmDataEntry call up another child form frmDealerSearch. If the user clicks on cancel on frmDealerSearch, I want to close frmDealerSearch and put the focus on txtDealerNum on...
6
by: Carl | last post by:
Hi you al I am new to this stuff and I found this code to close a form in the help files and I do not understand it or where its goe ' Calls this method from the InitializeComponent() method of...
3
by: Charles Law | last post by:
Under what circumstances would e.Cancel be set to True on entry to the Closing event of an MDI child form? I have found that this is why my application won't close properly. I can explicitly set...
3
by: Oenone | last post by:
I'm writing an application with various MDI child forms. In the Closing event of many of the forms, I have code that asks the user whether he is sure he wants to close the form, because it...
21
by: Darin | last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to handle textbox.validating, and I have the form setup so the Cancel button is the Cancel button. WHen the user clicks on...
2
by: Matuag | last post by:
Hi All, I want to create following command buttons on a Form which users can edit. Save ( Save Changes made) Cancel ( Undo data changes) Exit ( Close form) I am using Macros for each of...
5
by: jmarcrum | last post by:
Hey everybody! I've created 2 buttons that I've placed on all my forms: a Save button & a Cancel button. The cancel button I have a question about. I used the wizard to create the button...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.