Reference an open form

  • Thread starter Thread starter J. Garrido
  • Start date Start date
J

J. Garrido

I've been attempting to find out how this is accomplished in .NET,
because it appears to be far less simple then in 6. Essentially, I want to
be able to hide and display an existing form, instead of having to create a
new instance of the form everytime I need it. With VB 6 it was as simple as
form1.show and form1.hide, but in .NET, I'm at a loss; and I can never seem
to locate the information I need in the Library. Any pointers to where I
might find more information on the way forms are now handled would be
greatly appreciated.

- Jake G.
 
Dim MyForm as New YourFormName

MyForm.show()
MyForm.hide()


--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
 
Hi Terry, thanks for the quick reply, but the problem with that snippet
is that it will create a new instance everytime it is run. I need to
reference a pre-existing instance.

- JG
 
Create the instance at class level, then you can call it from anywhere in
the form, alternatively, declare a sub main and use that to call your main
form and declare the ones you need.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
 
* "J. Garrido said:
I've been attempting to find out how this is accomplished in .NET,
because it appears to be far less simple then in 6. Essentially, I want to
be able to hide and display an existing form, instead of having to create a
new instance of the form everytime I need it. With VB 6 it was as simple as
form1.show and form1.hide, but in .NET, I'm at a loss; and I can never seem
to locate the information I need in the Library. Any pointers to where I
might find more information on the way forms are now handled would be
greatly appreciated.

Google for the Singleton design pattern. By implementing this pattern,
you can access your form's default instances easily.
 
Back
Top