471,319 Members | 1,634 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Prevent form from closing

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
3 12848
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
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
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.

Similar topics

22 posts views Thread by alecjames1 | last post: by
9 posts views Thread by Daniel Walzenbach | last post: by
2 posts views Thread by Snuyt | last post: by
2 posts views Thread by kevininstructor | last post: by
7 posts views Thread by Michiel Rapati-Kekkonen | last post: by

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.