Detecting the instance of a form

D

DaveG

Hi All

I can create a Global boolean variable to be set when I create an
additional form and test the variable each time so I only have one
instance of that form.

If bFrm = False then
Form2.show
End If

Is there a way to check this without creating the global variable. I have
tried things like:

If Form2.Exists Then

But it's not allowed

Thanks in advance.

DaveG
 
C

Cor Ligthert

Dave,

In this kind of question is it important what kind of form you create

A midi
A showdialog
A normal show

For all these 3 are different ways to find what you want to know.

Cor
 
C

Cor Ligthert

DaveG.

That one has not much posibilities, however you can than go for the
Isdisposed when that is still not done than you can show it again., however
you should set your form than of course globaly

\\\
If frm.isdisposed then
frm = new formx
else
frm.show
end if
///

I hope this helps,

Cor
 
H

Herfried K. Wagner [MVP]

DaveG said:
I can create a Global boolean variable to be set when I create an
additional form and test the variable each time so I only have one
instance of that form.

If bFrm = False then
Form2.show
End If

Is there a way to check this without creating the global variable. I have
tried things like:

Implementing the Singleton Pattern in C#
<URL:http://www.yoda.arachsys.com/csharp/singleton.html>

Exploring the Singleton Design Pattern
<URL:http://msdn.microsoft.com/library/en-us/dnbda/html/singletondespatt.asp>

Design Pattern: Singleton in C#
<URL:http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=486>

Design Patterns: Singleton
<URL:http://www.dofactory.com/Patterns/PatternSingleton.aspx>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top