opening a new form question

hawk1ns

Active member
Joined
Jun 10, 2003
Messages
37
Hello .

I have used this line of code to open a new form :

Dim frmdataform3 As New DataForm3()
frmdataform3.Show()

This works fine but i find if user re-clicks on the button another copy of the form opens , it allows several copies of the same form to be open ...

How can i get it so that only 1 copy is to be open at any one time ?

sort of like :

if form open = true then dont open

:)

Thanks for help

Regards
Carl
 
Maybe if U declarar the frmdataform3 in the class and just run the frmdataform3.Show() then U open the, i think it will do it.
 
in the DataForm3 you could add some thing like
Code:
	Private Shared _IsOpen As Boolean

	Public Shared ReadOnly Property ISOpen() As Boolean
		Get
			Return _IsOpen
		End Get
	End Property

in the form load event add
Code:
_IsOpen = True

and
in the form closed event add
Code:
_IsOpen = false

in the code that creates the form you can now use code similar to
Code:
if DataForm3.Isopen = false then
donothing
else
create form here
end if
 
U sure that work, PlausiblyDamp ? :confused:
I dont think it work becurse he declarar the form in the function, and it will be declarar again as a new then he call the function again.
 
Declare your form as new on the top of your class, then from where ever you are calling just call it as
Code:
FormName.Show()
It will keep calling the same instance.
 
Why dont you keep your own boolean flag to indicate, whether form3 is already open or not ?

Or search for "Singleton" in this forum. The singletin design patter makes sure that a class is only instantiated once.
 

Similar threads

Back
Top