469,644 Members | 1,696 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,644 developers. It's quick & easy.

Terminating a windows form

Hi,

I am creating a windows form, and when a specified event occurs
(button click), I am hiding the windows form and opening a new windows
form. When opening the new windows form and closing it, the main
windows form would still be running in the background and never
terminating. How can I terminate the old window form from the new
created window.

I hope someone out there understands my problem.

Thanks and Regards
Nov 16 '05 #1
5 6394
use the static class Appplication

Application.Exit();

MajorTom
"Xarky" <be*********@yahoo.com> wrote in message
news:bc*************************@posting.google.co m...
Hi,

I am creating a windows form, and when a specified event occurs
(button click), I am hiding the windows form and opening a new windows
form. When opening the new windows form and closing it, the main
windows form would still be running in the background and never
terminating. How can I terminate the old window form from the new
created window.

I hope someone out there understands my problem.

Thanks and Regards

Nov 16 '05 #2
Sorry, this is for terminating the complete application

"MajorTom" <m.*********@verizon.net.do> wrote in message
news:#n**************@TK2MSFTNGP12.phx.gbl...
use the static class Appplication

Application.Exit();

MajorTom
"Xarky" <be*********@yahoo.com> wrote in message
news:bc*************************@posting.google.co m...
Hi,

I am creating a windows form, and when a specified event occurs
(button click), I am hiding the windows form and opening a new windows
form. When opening the new windows form and closing it, the main
windows form would still be running in the background and never
terminating. How can I terminate the old window form from the new
created window.

I hope someone out there understands my problem.

Thanks and Regards


Nov 16 '05 #3
Xarky wrote:
Hi,

I am creating a windows form, and when a specified event occurs
(button click), I am hiding the windows form and opening a new windows
form. When opening the new windows form and closing it, the main
windows form would still be running in the background and never
terminating. How can I terminate the old window form from the new
created window.

I hope someone out there understands my problem.


You only need to store the instance of the hidden window in a variable that
is accessible from your new window. If your new window is then closed it
calls Close() of the hidden window. But maybe I don't understand your
problem.

Boris
Nov 16 '05 #4
Xarky,

Hide() command will remove window from visibility only. Its still in the
memory.

Try this in your button click.

//first hide form 1
Form1.Hide()
//show the new form as modal
Form2.ShowDialog();
//when form 2 is closed, destrory form1
Form1.Close();

--
Shak
(Houston)


"Xarky" <be*********@yahoo.com> wrote in message
news:bc*************************@posting.google.co m...
Hi,

I am creating a windows form, and when a specified event occurs
(button click), I am hiding the windows form and opening a new windows
form. When opening the new windows form and closing it, the main
windows form would still be running in the background and never
terminating. How can I terminate the old window form from the new
created window.

I hope someone out there understands my problem.

Thanks and Regards

Nov 16 '05 #5
Hi,

When the initial form of a Windows application get's closed, then the whole application is terminated.

Hence, if the form you want to close is the startup form, then you will have to hide it, rather than close it.

--
Rakesh Rajan
"Xarky" wrote:
Hi,

I am creating a windows form, and when a specified event occurs
(button click), I am hiding the windows form and opening a new windows
form. When opening the new windows form and closing it, the main
windows form would still be running in the background and never
terminating. How can I terminate the old window form from the new
created window.

I hope someone out there understands my problem.

Thanks and Regards

Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Earl Eiland | last post: by
2 posts views Thread by machine | last post: by
6 posts views Thread by news.microsoft.com | last post: by
9 posts views Thread by SP | last post: by
35 posts views Thread by Aaron Gray | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.