• 0

[C#] Form management


Question

Another question guys... whats the best way to manage window forms?

Currently I have three forms - register, login and the main form (contains all the content once user logs on).

I understand that the following begins the first form - in which case will be my login screen

Application.Run(new Login());

What am I meant to do with this form once the user has logged in?

If i call the close command, just after another form is opened it actually closes both forms.

The only solution i can think of is to hide the login form once it is no-longer needed... messy though as i would manually have to close that form later.

or should the main form be called first, check if user has logged in... then open up a login or register form if necessary...

Thanks for any help...

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Thanks SharpGreen... Guessing i just call Application.Exit on the FormClosed event whenever i want the program to quit?

[edit:] Nope... The FormClosed button event would close the program even after a new form is created.

In this case when you call Application.Exit - im guessing it has to be called at some point?

Edited by Guest
Link to comment
Share on other sites

  • 0

Where are you creating the new form? in the login form or in the main method?

i suspect it is in the login form so when that is closed it will dispose of its self there by ending the new form.

you should show the login form as a dialog then when it exits find out should they be logged in or not then you can create the main form and show it from the main method.

Link to comment
Share on other sites

  • 0

I'd create a main form as well. In the main form's constructor, initialize and show the login for with .Show(). When you process the login, then display the main form.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.