how to disable multiple opening of forms
how can i disable multiple opening of forms.i have a mdi parent form,on other form i am using child.showdialog and it works perfectly.The problem comes when i have a form that has a button that opens another form..how do i restrict a user not to open other forms until this form is closed because when i use show.dialog on the other form that opens a new one the former remains in the background while i want it to close
Re: how to disable multiple opening of forms
Not sure how many forms you are using, but if it is not to many, I would just use an If then statement
If Form2.visible = False or Form3.visible = False then
' Show whatever form needs to be shown
Else
exit sub ' do nothing
End If
Exit Sub exits the process, so nothing happens
Another way you might go is accessing the forms collection, but I would only do that if
you have a large number of forms.
Re: how to disable multiple opening of forms
thanks for the response. i have incorporated your idea and i have
if me.visible = true then
frmmainmenu.enabled=false
elseif me.visible=false then
frmmainmenu.enabled=true
end if
but the main menu is remaining disabled once i open the me form(being the form new customer) and if i close the form that has the button to open the me form it still remains disabled
Re: how to disable multiple opening of forms
Where is this code exactly? In any case if me.Visible = false never applies because if me.Visible = false then me.running code = false too!
vb.net Code:
' On Form2 which is your "Me"
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Form3.Show ' this is the form you only want one of
Me.Close()
End Sub
' On Form3
Private Sub Form3_FormClosed(sender As System.Object, e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
Form2.Show()
End Sub
Re: how to disable multiple opening of forms
i put the code on the main form ie the mdi. the me is referring to the form i am opening ie frmnewcustomer
if frmnewcustomer.visible= true then
radmenu.enabled = false
else if frmnewcustomer.visible=false then
radmenu.enabled = true
exit sub
end if
Re: how to disable multiple opening of forms
I don't care which form it's on, what event is it using? Can you really not see the difference in detail between my code samples and yours? Did you even try the suggestion I made?