473,408 Members | 2,839 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,408 software developers and data experts.

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 10101
"John S" <jo********@cinfin.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
/frlrfSystemWindowsFormsFormClassClosingTopic.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********@cinfin.com> wrote in message
news:uF**************@TK2MSFTNGP12.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"

"Beeeeeeeeeeeeves" 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***@discussions.microsoft.com> wrote in message
news:5E**********************************@microsof t.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"

"Beeeeeeeeeeeeves" 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
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...
2
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. ...
5
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
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); //...
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...
4
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...
2
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...
1
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
0
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...
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,...
0
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...
0
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,...
0
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...

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.