Closing Forms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dan

    #1

    Closing Forms

    All,

    I have an application that starts by displaying a logon
    form to the user. If they enter the correct information
    another form is to be displayed and the logon form closed.

    The problem I have is in closing the logon form. If I use
    the close method

    frmLogOn.Close( )

    the entire program terminates. I can set the visible
    property to false which removes it from the screen but it
    is still loaded. How do I close the logon form without
    terminating the application. Thanks for the help!

    Dan
  • Eric Cadwell

    #2
    Re: Closing Forms

    Your setting the logon form as the Main Form of the application. When this
    form closes it shuts down the application.

    static void Main()
    {
    Application.Run (new LogonForm());
    }

    Use the ApplicationCont ext overload of Application.Run or set the Main Form
    properly. Or you could show the logon form prior to calling Application.Run ;

    static void Main()
    {
    Form logon = new LogonForm();
    if (logon.ShowDial og() == DialogResult.OK ) // let them in
    Application.Run (new MainForm());
    }

    HTH;
    -Eric


    Comment

    Working...