New to C# (Really) Hide / show form that has already been loaded?

RyanJones

Newcomer
Joined
Apr 22, 2006
Messages
2
Location
Rhondda Cynon Taff, Wales.
Hi all.

I am new to C# (2 days learning) and I seen to have a problem. I have a form named frmMain that is the form initally loaded (starting form). How can I hide and show this from from another class?

Do I need to use an object variable or is there another way to do this? (Have tried frmMain.Show() and frmMain.Hide() but they do not work).

Thanks for the help,

Ryan Jones
 
You can only access objects that are currently in scope. If you are using your frmMain to create for example a frmOptions, unless you pass frmOptions a reference (or store a static reference). There have been quite a few questions like this on the forum so a search should turn up a result. As a starting point if you setup the additional form to accept frmMain as a parameter, you can then store a local reference allowing you to Show() and Hide() the form whenever you want.
 
Back
Top