473,769 Members | 5,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Closing application from another form

I have an application in which the main form goes something like:

public frmMain()
{
frmA frm = new frmA();
frm.show();
this.hide();
}

Now that the control has been passed to frmA, how do I close the
application from frmA

Can anybody help?

Regards

Jul 28 '06 #1
6 2104
"ah*********@gm ail.com" wrote:
I have an application in which the main form goes something like:

public frmMain()
{
frmA frm = new frmA();
frm.show();
this.hide();
}

Now that the control has been passed to frmA, how do I close the
application from frmA
You could:
1. Call Application.Exi t()
2. Tell the now-hidden main form to close.
~~~~~~~~~~~~~~~ ~~~

Timm Martin
Mini-Tools
..NET Components and Windows Software
http://www.mini-tools.com

Jul 28 '06 #2
Hi,
Appliaction.Exi t or frmMain.Close will solve it, the first can be called
from anypoint. the second would need to pass a reference to the frm form.
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

<ah*********@gm ail.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
>I have an application in which the main form goes something like:

public frmMain()
{
frmA frm = new frmA();
frm.show();
this.hide();
}

Now that the control has been passed to frmA, how do I close the
application from frmA

Can anybody help?

Regards

Jul 28 '06 #3
No application.exi t() doesn't work,
Actually the thing that is happening is that the program starts up from
a main.cs file, which calls this frmMain something like this:

Application.Run (new frmMain());

After that frmMain calls this new frmA and hides itself. My problem is
I'm not able to close the application from frmA.
<quote2. Tell the now-hidden main form to close.<end-quoteand how
will I do this, cause I dont know to where the control will be passed
to the frmMain when frmA closes.

Thanks for helping.

Regards
Mini-Tools Timm wrote:
"ah*********@gm ail.com" wrote:
I have an application in which the main form goes something like:

public frmMain()
{
frmA frm = new frmA();
frm.show();
this.hide();
}

Now that the control has been passed to frmA, how do I close the
application from frmA

You could:
1. Call Application.Exi t()
2. Tell the now-hidden main form to close.
~~~~~~~~~~~~~~~ ~~~

Timm Martin
Mini-Tools
.NET Components and Windows Software
http://www.mini-tools.com
Jul 28 '06 #4
No application.exi t() doesn't work,
Actually the thing that is happening is that the program starts up from
a main.cs file, which calls this frmMain something like this:

Application.Run (new frmMain());

After that frmMain calls this new frmA and hides itself. My problem is
I'm not able to close the application from frmA.
<quote2. Tell the now-hidden main form to close.<end-quoteand how
will I do this, cause I dont know to where the control will be passed
to the frmMain when frmA closes.

Thanks for helping.

Regards

Mini-Tools Timm wrote:
"ah*********@gm ail.com" wrote:
I have an application in which the main form goes something like:

public frmMain()
{
frmA frm = new frmA();
frm.show();
this.hide();
}

Now that the control has been passed to frmA, how do I close the
application from frmA

You could:
1. Call Application.Exi t()
2. Tell the now-hidden main form to close.
~~~~~~~~~~~~~~~ ~~~

Timm Martin
Mini-Tools
.NET Components and Windows Software
http://www.mini-tools.com
Jul 28 '06 #5
Understood what the problem was !
I had a bunch of lines of code below Application.Exi t(), and I was
thinking that the application would exit immediately after coming on
Application.Exi t(). But CLR makes the whole method finish in which
Exit() was called before killing all threads and forms of the app.

Thanks to everybody who helped.

Jul 29 '06 #6
Understood what the problem was !
I had a bunch of lines of code below Application.Exi t(), and I was
thinking that the application would exit immediately after coming on
Application.Exi t(). But CLR makes the whole method finish in which
Exit() was called before killing all threads and forms of the app.

Thanks to everybody who helped.

Jul 29 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5823
by: Chris Bruce | last post by:
In my application I need a way to distiguish between the following events: 1. When a user closes an MDI child window. 2. When the user closes the MDI parent window which subsequently closes the MDI child window. My application does certain logic when the user actually closes the MDI child form by clicking the "X" in the upper right hand. My application, however, should not execute this logic if the user closes the MDI parent. I...
3
1463
by: Brad Allison | last post by:
Is there an easy way to close one form when another opens? Thanks for the information. Brad
10
4029
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
3
2776
by: Charles Law | last post by:
Under what circumstances would e.Cancel be set to True on entry to the Closing event of an MDI child form? I have found that this is why my application won't close properly. I can explicitly set the value to False, but I would have expected it to be False on entry. TIA Charles
10
1833
by: Ricky W. Hunt | last post by:
I have written a close routine to handle an "Exit" button to close the application properly. How do I make sure this gets executed if the user closes it another way (by pressing the "X" in the upper right hand for instance, or Alt+4, etc.) Or is this even necessary? -- Thanks, Ricky W. Hunt freendeed
14
3366
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS2005 and .net 2.0. I'm creating an application that has 3 forms. I want allow users to move forward and backward with the forms and retain the data users have entered. I thought I'll make the inactive forms invisible but this is creating a memory corruption problem when user close the form2 or form3 and not the formMain. My main form has a Next button which makes the main form invisible and starts a new form which I'll...
22
3091
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is changing. But, the form may not exist (it is created / destroyed at user request). I can check form != null to prevent incorrect access. But, the form could disappear immediately after the check, before the method is run. Or someone could click 'close' when it's in the middle of an update. ...
12
1507
by: kronecker | last post by:
I found this nifty routine that closes a form one by one every time it is called. However, I need to hide them instead of closing them. Is there a way to alter the code? I assume it has something to do with this line here... PostMessage(i, CInt(&H10), vbNullString, vbNullString) Thanks
2
4234
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
I am (still) relatively new to Windows applications, most of my experience has been Web based, and I am confused about what exactly happens when the Main() method is called and how to manipulate forms opening & closing. An example of this issue is as follows. I have a logon form open as the first thing. The main functional form opens when a user has successfully logged on. From the main form, a user should be able to logout which will...
13
2589
by: SvenV | last post by:
Hello, Currently I'm developing an application for a Windows CE 4.0 device. This application contains a lot of different forms. The application jumps from one form to another. And I close the forms when I go to another form but I don't think it's the best way to close them. Sometimes, at random moments, I receive a StackOverflowException and on the device I see a lot of forms closing, you see the behavior that you normally get when you form...
0
9590
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9424
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10051
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9866
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8879
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3968
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.