473,322 Members | 1,379 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,322 software developers and data experts.

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 6560
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Earl Eiland | last post by:
I'm running a PyWin program that executes another program using subprocess.Popen(). Unfortunately, this other program isn't well behaved, and frequently terminates without terminating its process....
2
by: Byron | last post by:
I'm new to C# and threading, so hopefully this is a simple newbie question. I have a form that is supposed to listen for network traffic on a given port and decode and display any interesting...
3
by: Jon Bosker | last post by:
I have written an application that lives in the systray but when I try to close windows or logout it does not close my application and therefore prevents windows from shutting down or logging me...
2
by: machine | last post by:
I'm automating word form a c# windows application for spell checking purposes. The problem is that sometimes the winword.exe process does not terminate. Any clues why? I posted some code below....
6
by: news.microsoft.com | last post by:
I have a very multi-threaded Windows Forms application. There are many BeginInvoke calls, as well as Thread/ThreadStarts. My issue is that when I quit my application there are often threads...
9
by: SP | last post by:
Hi All, I wrote a windows service which is supposed to stop after specified amount of time. I am calling OnStop() after specified time. OnStop() methods executed but I dont see the service...
35
by: Aaron Gray | last post by:
Hi, I have some code I just cannot seem to get to work properly on FireFox. It is probably something simple. On FireFox the following code does not seem to terminate in the browser, but it...
10
by: Zytan | last post by:
Threads are not auto-terminated when the main form closes (not that they should be). What's the best way to terminate them when the program exits? Catch the on close message of the form, and give...
4
maxx233
by: maxx233 | last post by:
Hello! I have an app that starts up and has a starting form. One of the icons on this beginning Form opens a new form and lets the user give some information on a task they need to remember to do...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.