After the user inputs idnum and password. If thats correct the loginwindow is suppose to minimize and the mainwindow is suppose to come up. The main window comes up but the login window wont go away.
:icon_evil
login window http://i41.tinypic.com/15ceblf.png main window http://i40.tinypic.com/121v2bk.png my problem http://i43.tinypic.com/4sjvy0.png

if (userName_login_window.Equals("1") && pass_login_window.Equals("2"))
          {
             
              MainWindow window = new MainWindow();
              window.ShowDialog();//Brings up the main window
              Application.Exit();//suppose to close login window but doesnt work.
              
              
              
          }

HELP Greatly needed.

Recommended Answers

All 4 Replies

If the login windows is the default Form of your application then you should hide it. Because if you close it it'll close the application.

Here's an example:

if (userName_login_window.Equals("1") && pass_login_window.Equals("2"))
{
             
MainWindow window = new MainWindow();
window.ShowDialog();//Brings up the main window
[B]this.Hide();[/B]
                                    
}

Thanks for the advice but its still not working.
I was wondering if i can put the code in the main window to hide the login form when its triggered.

if (userName_login_window.Equals("1") && pass_login_window.Equals("2"))

{
             
MainWindow window = new MainWindow();
window.ShowDialog();//Brings up the main window
this.Hide();// The same problem exist. 
                                    
}

Oh sorry! I didn't notice you are using ShowDialog(). Code added after ShowDialog() is executed after the form is closed.

To make it work just put the this.Hide(); line before ShowDialog() and it'll work:

if (userName_login_window.Equals("1") && pass_login_window.Equals("2"))
{            
MainWindow window = new MainWindow();
[B]this.Hide();[/B]
window.ShowDialog();                                   
}

Thanks

Thanks it works. Cheers to farooqaa...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.