473,624 Members | 2,453 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 12537
Hi,

**
Private Sub Form1_Closing(B yVal sender As Object, ByVal e As
System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
Dim dlgres As DialogResult = _
MessageBox.Show ("Are you shure you want to close this
widnow?", _
"MyApp", _
MessageBoxButto ns.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******@hotma il.com> wrote in message
news:uH******** ******@TK2MSFTN GP10.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.vod atel.hr...
Hi,

**
Private Sub Form1_Closing(B yVal sender As Object, ByVal e As
System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
Dim dlgres As DialogResult = _
MessageBox.Show ("Are you shure you want to close this
widnow?", _
"MyApp", _
MessageBoxButto ns.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******@hotma il.com> wrote in message
news:uH******** ******@TK2MSFTN GP10.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******@hotma il.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
2516
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 user wants to save the data, but when the Application closes this event isn't thrown automatically. I added a loop to close each child window, but can't seem find how to catch the child window's cancel of the Closing event, so even if the user...
0
2029
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 MainForm.cs... //I Don't want the main form to close with enter and esc keys... MainForm.AcceptButton = None; //Not in code... MainForm.CancelButton = None; //Not in code...
13
2312
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 frmDataEntry. Here is my code. public class frmDataEntry : System.Windows.Forms.Form { private void txtDealerNum_Leave(object sender, System.EventArgs e) {
6
8563
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 your form Private Sub OtherInitialize( AddHandler Me.Closing, AddressOf Me.Form1_Cance End Sub 'OtherInitializ Protected Sub Form1_Cancel(sender As Object, e As CancelEventArgs If Not myDataIsSaved The
3
2770
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 the value to False, but I would have expected it to be False on entry. TIA Charles
3
6365
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 contains unsaved data. If the user clicks "No" then the code sets e.Cancel = True, which cancels the closure. This works just great. But when the user closes the MDI parent form, the cancellation seems to be completely ignored. The MessageBox...
21
9151
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 the cancel button, the textbox.validating is being called. I don't want it to be since they are exiting the screen the validation doesn't have to be done. How can I do that.
2
11859
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 these commands and they work perfect.
5
9862
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 and I selected the Record Operations/Undo Record option. I edited the vba code to have the button also close the form after it undoes any changes. Here is the actual code for the OnClick event for the cancel button: Private Sub cmdCancel_Click()...
0
8240
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8680
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8625
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7168
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6111
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

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.