By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,098 Members | 1,893 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,098 IT Pros & Developers. It's quick & easy.

Prevent form from closing

P: n/a
i want to prevent a form from closing..

to do this i want to handle the formClosing or FormClosed events.
from here i want to prevent the form from closing.

New instance of same form should not be used.

is there any way to do this?

is it posiible to do the same thing with anycode?

[i posted the same thing in VB. sorry if u find that too... reply in
one post is enough]

Jun 14 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Wed, 13 Jun 2007 18:57:15 -0700, sravan_reddy001
<sr*************@gmail.comwrote:
i want to prevent a form from closing..
http://groups.google.com/groups/sear...=Search+Groups
[...]
[i posted the same thing in VB. sorry if u find that too... reply in
one post is enough]
Please learn to cross-post properly, by including all newsgroups in
Newsgroups: field of the same post, instead of multi-posting.

Pete
Jun 14 '07 #2

P: n/a
On 14 Jun., 03:57, sravan_reddy001 <sravanganta2...@gmail.comwrote:
i want to prevent a form from closing..

to do this i want to handle the formClosing or FormClosed events.
from here i want to prevent the form from closing.

New instance of same form should not be used.

is there any way to do this?

is it posiible to do the same thing with anycode?

[i posted the same thing in VB. sorry if u find that too... reply in
one post is enough]
Setting e.Cancel to true in the FormClosing-event should do the trick.

hth,
Kevin Wienhold

Jun 14 '07 #3

P: n/a
Hi,

"KWienhold" <he******@trashmail.netwrote in message
news:11*********************@i13g2000prf.googlegro ups.com...
On 14 Jun., 03:57, sravan_reddy001 <sravanganta2...@gmail.comwrote:
>i want to prevent a form from closing..

to do this i want to handle the formClosing or FormClosed events.
from here i want to prevent the form from closing.
>
Setting e.Cancel to true in the FormClosing-event should do the trick.
You need something else, you need a flag to know when the form is closing
from the code or is the user trying to close it.

bool canClose = false;

void form_Closing(.... )
{
e.Cancel = !canClose;
}

so if you want to close the form you do:

canClose =true;
Close();
Jun 14 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.