473,666 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stop form from closing

When the user clicks the "X" in the upper right-hand corner of a form, how
can I stop the form from closing?
Nov 16 '05 #1
6 10120
"John S" <jo********@cin fin.com> wrote:
When the user clicks the "X" in the upper right-hand
corner of a form, how can I stop the form from closing?


Handle the Form Closing event and set e.Cancel = true.

Be aware that overriding what the user wants to do can be rather
annoying.

P.
Nov 16 '05 #2
Elp
John S wrote:
When the user clicks the "X" in the upper right-hand corner of a
form, how can I stop the form from closing?


You have to handle the Closing event and take appropriate action (ie set the
Cancel property of the event's arg to true). Have a look at the doc for this
event for all implications of doing that. This is very simple to do but this
may lead to other problems if you are not careful:
<http://msdn.microsoft.com/library/de...-us/cpref/html
/frlrfSystemWind owsFormsFormCla ssClosingTopic. asp>
Nov 16 '05 #3
Hi,

Handle the form's Closing event and set the event argument's Cancel property
to true.

"John S" <jo********@cin fin.com> wrote in message
news:uF******** ******@TK2MSFTN GP12.phx.gbl...
When the user clicks the "X" in the upper right-hand corner of a form, how
can I stop the form from closing?

Nov 16 '05 #4
Simply don't have an X button.
Set the ControlBox property of the form to false.

"John S" wrote:
When the user clicks the "X" in the upper right-hand corner of a form, how
can I stop the form from closing?

Nov 16 '05 #5
Patient: "Doc, how do I stop my arm from hurting when I raise it above my head"
Doc: "Don't raise it above your head"

"Beeeeeeeeeeeev es" wrote:
Simply don't have an X button.
Set the ControlBox property of the form to false.

"John S" wrote:
When the user clicks the "X" in the upper right-hand corner of a form, how
can I stop the form from closing?

Nov 16 '05 #6
Hi,

LOL

also you can handle the Closing event and set the Cancel property to true

very easy :) you still get the X as the user expect but you have control
over the closing

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Steve" <St***@discussi ons.microsoft.c om> wrote in message
news:5E******** *************** ***********@mic rosoft.com...
Patient: "Doc, how do I stop my arm from hurting when I raise it above my head" Doc: "Don't raise it above your head"

"Beeeeeeeeeeeev es" wrote:
Simply don't have an X button.
Set the ControlBox property of the form to false.

"John S" wrote:
When the user clicks the "X" in the upper right-hand corner of a form, how can I stop the form from closing?

Nov 16 '05 #7

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

Similar topics

16
1920
by: ThunderMusic | last post by:
Hi, My app does not stop whan I click on the form. I mean, the form is closing, but the process keeps running in the task manager. So I figured there are memory leaks or some object's process stuck at some point. Is there an easy way to know where it comes from other than putting breakpoints all over the code? 'cause it's huge and I would have to set breakpoints for at least a day or two thanks
2
4093
by: Julia Baresch | last post by:
Hi everyone, As some of you may know, we've been having trouble with an unrecognized database format error. Today I installed an unfinished project on the workstation of one of my users. It's a query by form in which she enters the criteria of the record she wants in an unbound form, and it pulls only that record and switches to the entry form so she can enter data. I had noticed it was faster than find or filter, so I offered it to...
5
73205
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
8
2303
by: Tim Bücker | last post by:
Following scenario: The user opens a form, a thread is started to play a sound ... public void playSoundUsingThread() { if (File.Exists(fileLocation)) PlaySound(fileLocation, 0, 0); // winmm.dll }
3
1921
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 check some conditions and if those conditions doesnt meet, then I want to stop the VS.NET window from closing. Anybody have any diea?
4
5843
by: SteveK | last post by:
Hi- I have created a basic login form. If the user enters invalid credentials, I want to display an error. However, when the user presses the Login button, the dialog closes... I'm sure this is normal, but how can I interupt this and keep the dialog alive until I am ready for it to close? Thanks, Steve
2
2036
by: Bob Cummings | last post by:
Greetings I am sure this is a simple question. But I have "googled" it to death and have only found one answer that involved a bunch of window's API calls that I did not understand. I am a student taking VB.NET and we are studying the Validation event and how to use it on text boxs. I have set the forms.causevalidation property to false. But if the user has bad data in the text box and just wants to quit the program by clicking on...
1
2319
by: JohnR | last post by:
I have a form that is presented in an mdi child window. If the user hits exit or the X button on the titlebar of the mdi child form, that form's "closing" event fires and in that event I check to see if there are any outstanding database changes that have not been saved. If there are I give the user the option of abandoning the closing of the form by issuing a "e.cancel" statement. This works perfectly if the user hits the X in the...
2
4213
by: RajaKannan | last post by:
Hi All, I have a form in which i have few mandatory fields. Wheneve the user tries to save, i check for these fields and alert them, if thet are empty. I have a CLOSE button in my form and whenever the user clicks the CLOSE button, i ask the user whether he wants to save before closing the form. On the Form_Unload event, i check whether there are any new changes and if yes, i pompt the user for a save. But if they have not filled any of...
0
8360
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
8876
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
8784
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...
0
8642
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
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
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...
1
2774
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1777
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.