C#: Close and Open two forms from a separate form -
i have 3 forms. how can make 1 form shown .show() , other hidden .hide() separate form?
this part of code
private void buttonyes_click(object sender, eventargs e) { loggedin loggedinform = new loggedin(); loggedinform.hide(); // hides form in background mainform mainform = new mainform(); mainform.show(); // show first form this.hide(); // hides current form }
one problem, loggedin form not hide itself. looks of it skips , goes mainform.show();
is bug or need else?
the line loggedin loggedinform = new loggedin()
going create new instance of login window. might useful if, say, intended show 5 "login" windows onscreen @ once. think want retrieve reference login window showing, , hide that; so, avoid creating new one.
properly passing references existing objects around program kind of structural problem, , 1 ran quite bit in programming days. quick, unclean, , not-recommended way declare instances of singular objects (like, maybe, login window) static
, can retrieved anywhere. however, answer question in best way, maybe describe structure of program bit more (full code isn't necessary, generally-speaking, flow between classes)
Comments
Post a Comment