Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Application tab in C#

Tommy1402Tommy1402 Posts: 6Member
If we use VB, in its Application tab in Project Properties menu, we can choose the shutdown mode to "... the last form close". so in VB, the application will terminate when the last Form is closed.

How do I do that with C#? because when I closed (using syntax: this.close()) my Form1 (Form1 activates Form2), my application terminated.

What I want is,
when I start to compile, Form1 actives, then after I press Login button on Form1, Form1 closes (but NOT hide - ) then Form2 shows up.

Any help?
thanks

Comments

  • IDKIDK Posts: 1,784Member
    : If we use VB, in its Application tab in Project Properties menu, we can choose the shutdown mode to "... the last form close". so in VB, the application will terminate when the last Form is closed.
    :
    : How do I do that with C#? because when I closed (using syntax: this.close()) my Form1 (Form1 activates Form2), my application terminated.
    :
    : What I want is,
    : when I start to compile, Form1 actives, then after I press Login button on Form1, Form1 closes (but NOT hide - ) then Form2 shows up.
    :
    : Any help?
    : thanks
    :
    First, why can't it hide?

    I would do like this only becouse it's so cool: create a server and then create clients to that server.

    The server should fire up a client (the login form), and when that connection is closed, it fires up another form...
  • tsagldtsagld Posts: 621Member
    : If we use VB, in its Application tab in Project Properties menu, we can choose the shutdown mode to "... the last form close". so in VB, the application will terminate when the last Form is closed.
    :
    : How do I do that with C#? because when I closed (using syntax: this.close()) my Form1 (Form1 activates Form2), my application terminated.
    :
    : What I want is,
    : when I start to compile, Form1 actives, then after I press Login button on Form1, Form1 closes (but NOT hide - ) then Form2 shows up.
    :
    : Any help?
    : thanks
    :
    What do you mean, 'form1 closes, but doesn't hide')?. That's impossible.
    Anyway, a C# application always has a static Main(string[] args) function, which is called by the framework at startup.
    There, you can open your forms and call Application.Run(form) to enter the messageloop for the form.
    As soon as a form closes, the app returns to the statement after the Application.Run() where you can do whatever you like. For example, let Main finish.

    Greets,
    Eric Goldstein
    http://www.gvh-maatwerk.nl


  • Tommy1402Tommy1402 Posts: 6Member
    Not like that. Here's what I mean.
    I just want to Display one Form at a time. Right now I'm designing a Login Form which on success, a Main Form is opened and the Login Form is Closed. By using VB, it can be done very easily (in Project Properies -> tab Application -> Shutdown mode -> choose: Application terminate on last form closes). So, there is some resource saving because Login Form is closed.

    But in C# there's no option like in VB. Instead, in my C#, When Login Form closes, the entire application is terminated including my Main Form.

    Right now the only solution I did, is hiding the Login Form (opacity = 0) but I believe it's not good in term of programming right?
    so, any solution?

    : : If we use VB, in its Application tab in Project Properties menu, we can choose the shutdown mode to "... the last form close". so in VB, the application will terminate when the last Form is closed.
    : :
    : : How do I do that with C#? because when I closed (using syntax: this.close()) my Form1 (Form1 activates Form2), my application terminated.
    : :
    : : What I want is,
    : : when I start to compile, Form1 actives, then after I press Login button on Form1, Form1 closes (but NOT hide - ) then Form2 shows up.
    : :
    : : Any help?
    : : thanks
    : :
    : What do you mean, 'form1 closes, but doesn't hide')?. That's impossible.
    : Anyway, a C# application always has a static Main(string[] args) function, which is called by the framework at startup.
    : There, you can open your forms and call Application.Run(form) to enter the messageloop for the form.
    : As soon as a form closes, the app returns to the statement after the Application.Run() where you can do whatever you like. For example, let Main finish.
    :
    : Greets,
    : Eric Goldstein
    : http://www.gvh-maatwerk.nl
    :
    :
    :

  • tsagldtsagld Posts: 621Member
    : Not like that. Here's what I mean.
    : I just want to Display one Form at a time. Right now I'm designing a Login Form which on success, a Main Form is opened and the Login Form is Closed. By using VB, it can be done very easily (in Project Properies -> tab Application -> Shutdown mode -> choose: Application terminate on last form closes). So, there is some resource saving because Login Form is closed.
    :
    : But in C# there's no option like in VB. Instead, in my C#, When Login Form closes, the entire application is terminated including my Main Form.
    :
    : Right now the only solution I did, is hiding the Login Form (opacity = 0) but I believe it's not good in term of programming right?
    : so, any solution?
    :
    : : : If we use VB, in its Application tab in Project Properties menu, we can choose the shutdown mode to "... the last form close". so in VB, the application will terminate when the last Form is closed.
    : : :
    : : : How do I do that with C#? because when I closed (using syntax: this.close()) my Form1 (Form1 activates Form2), my application terminated.
    : : :
    : : : What I want is,
    : : : when I start to compile, Form1 actives, then after I press Login button on Form1, Form1 closes (but NOT hide - ) then Form2 shows up.
    : : :
    : : : Any help?
    : : : thanks
    : : :
    : : What do you mean, 'form1 closes, but doesn't hide')?. That's impossible.
    : : Anyway, a C# application always has a static Main(string[] args) function, which is called by the framework at startup.
    : : There, you can open your forms and call Application.Run(form) to enter the messageloop for the form.
    : : As soon as a form closes, the app returns to the statement after the Application.Run() where you can do whatever you like. For example, let Main finish.
    : :
    : : Greets,
    : : Eric Goldstein
    : : http://www.gvh-maatwerk.nl
    : :
    : :
    : :
    :
    If the app auto-closes after the login form closes, you are doing something wrong. Maybe post some code where you create/show the form.



    Greets,
    Eric Goldstein
    http://www.gvh-maatwerk.nl


  • IDKIDK Posts: 1,784Member
    : Not like that. Here's what I mean.
    : I just want to Display one Form at a time. Right now I'm designing a Login Form which on success, a Main Form is opened and the Login Form is Closed. By using VB, it can be done very easily (in Project Properies -> tab Application -> Shutdown mode -> choose: Application terminate on last form closes). So, there is some resource saving because Login Form is closed.
    :
    : But in C# there's no option like in VB. Instead, in my C#, When Login Form closes, the entire application is terminated including my Main Form.
    :
    : Right now the only solution I did, is hiding the Login Form (opacity = 0) but I believe it's not good in term of programming right?
    : so, any solution?
    :

    Ever heard of .hide() ?
  • Tommy1402Tommy1402 Posts: 6Member
    Of course I ever heard it. For information, I'm using Visual Studio 2005.
    Tomorrow I'll post the code.
    Thanks Again
    :
    : Ever heard of .hide() ?
    :

Sign In or Register to comment.