To close a form which is parent from child autometically follwing are the rules .
say we have two forms name login winform and another is mainform we want to go mainform when click on login button then mainform will open and login form will close autometically.
when login button click event follwong code will be -
private void btnlogin_Click(object sender, EventArgs e){mainform newmainwindow = new mainform();newmainwindow.Show(this);this.Hide();}
and then main form will load follwoing method need to call
protected override void OnClosing(CancelEventArgs e){Owner.Close();}
It will work .
No comments:
Post a Comment