Switching between two forms

Posted 19 February 2013 - 01:30 AM

I will have form1 which will always remain open. Then I have my form2 which gets displayed when user clicks a button in form1 and populates some picture in form2. Later when the user finishes viewing form2 and selects form1 again from taskbar, form2 must be closed automatically. This routine has to be repeated for a particualr button click event from form1.

Which event do I have to add the code to show and hide my form2?

Form1.Activated or Form1.Click or Form1.Enter or and so on.. Which would be the best event?

Replies To: Switching between two forms

Re: Switching between two forms

Posted 19 February 2013 - 06:10 AM

If I recall correctly, you'll need the Activated event for the case when the user clicks on the task bar, or clicks on the form to bring focus back to it. Assuming that works, then I don't see a need for a button on Form1 to hide Form2 since whenever Form1 is active and has focus, you should have already hidden Form2 by that time.

Re: Switching between two forms

Posted 19 February 2013 - 06:55 AM

[*]Q: ...get Form/class 'A' to make a change or talk to Form/class 'B'

Spoiler

NOTE: Don't try to access GUI controls across forms. Its wrong. Nobody will hire you if you do this sort of crap. It violates every guideline for 'black box' programming, Separation of Responsibility, loose binding of components, and event driven programming. Read the tutorials and learn to do it right the first time so you don't develop bad habits that you just have to un-learn later. A: