hawk1ns Posted July 6, 2003 Posted July 6, 2003 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 Quote
xSwan Posted July 6, 2003 Posted July 6, 2003 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. Quote
Administrators PlausiblyDamp Posted July 6, 2003 Administrators Posted July 6, 2003 in the DataForm3 you could add some thing like 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 _IsOpen = True and in the form closed event add _IsOpen = false in the code that creates the form you can now use code similar to if DataForm3.Isopen = false then 'donothing else 'create form here end if Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
xSwan Posted July 6, 2003 Posted July 6, 2003 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. Quote
*Experts* mutant Posted July 6, 2003 *Experts* Posted July 6, 2003 Declare your form as new on the top of your class, then from where ever you are calling just call it as FormName.Show() It will keep calling the same instance. Quote
Heiko Posted July 6, 2003 Posted July 6, 2003 Why don't 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. Quote .nerd
JCreationsInc Posted July 7, 2003 Posted July 7, 2003 Sounds like you should set a boolean data type and check it when the button is clicked to make sure the procedure doesnt open another window. :D Quote When in doubt.... use the sledge Hammer!!
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.