Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to open form when click button?

Status
Not open for further replies.

nguyentaiuyenchi

Technical User
Nov 5, 2001
39
VN
Hi all,

I have just started with C# so there are something that seem very simple but I can not control it -). Please help me:
- I have two forms (frmLogin and frmMain)
- When I start application, frmLogin is load.
- I click OK button on frmLogin: I want unload frmLogin and show frmMain but I do not know how to do it.

Thanks
Uyen Chi
Software developer

Atlasindustries Ltd.
Viet Nam
 
On the clicking of the button you want to use :
frmMain.Show();
This assumes that the form is already created.

In order to close the original form you could use the 'Load' event for the frmMain form and use the syntax :
frmLogin.Hide();

Alternatively you could call the 'Hide()' from the first form.

I'm suggesting these off the top of my head so they may not be 100%. I'm new to this myself.

Steve

 
Hi StevenK,

Thank you for your helping.
I have done as your showing and it is working very well. However I don't know when do we free frmLogin. (maybe frmMain unload???).
If we do not call frmLogin.Close() then after closing frmMain the application has still been in memory....

Once again, thank you very big...

Uyen Chi Uyen Chi
Software developer

Atlasindustries Ltd.
Viet Nam
 
In the Load event of frmMain

frmLogin.Close. The garbage collector will deal with disposing of the object.

Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top