0

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.

Edited by jamdownian: n/a

2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by jamdownian
0

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]
                                    
}
0

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. 
                                    
}
0

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

Edited by farooqaaa: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.