I have Two windows MainWindow and Login. The button which shows login located on mainWindow
this.Hide();
Login li = new Login();
li.Show();
on Login Window is button which checks password how i can show MainWindow if password is correct?
pass a parameter to the loginwindow of type MainWindow. That allows the Login window to have a reference to the MainWindow:
this.Hide();
Login li = new Login(this);
li.Show();
And the login window:
private MainWindow m_parent;
public Login(MainWindow parent){
m_parent = parent;
}
//Login Succesfull function
private void Succes(){
m_parent.Show();
}
first answer is good but it'll create a new empty window to avoid this problem ( redirect to a previously created window) just modify constructor like this
public Login(MainWindow parent):this()
{
m_parent = parent;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With