Hi,
I created a Parent form and a main menu, where user can select and click a menu item and Show a child MDI form. I'm able to add a "tick" beside this menu item on the main menu, but how can I "disable" this menu item so that user can NOT click on this menu item AGAIN and open n x this child form

Open Child Window ONCE
Annuzzer
Matt
rkvajrala
Create a Function:
Private Function CheckIfOpen(ByVal frmName As String) As Boolean
Dim frm As Form
For Each frm In Me.MdiChildren
If frm.Name = frmName Then
frm.Focus()
Return true
Exit Function
End If
Next
Return False
End Function
add code to where you open the form. (menu or button)
If CheckIfOpen("frmVoidPrintedCoupons")=False Then
Dim fv As New frmVoidPrintedCoupons
fv.MdiParent = Me
fv.Show()
End If
Pass the name of the child window to the function. Loop through each mdichild. If found then set forcus to the one that is open else return true and open the window for the first time.
There might be a better way to do this, If so please let me know.
Matt
MichaelP_Oxy
I put up a set of overloads I use.
basiclly same as above, but I pass in type rather than name, and a few other parameters in the overloads to call specific commands such as focus and close.
nothingbutdotnet
However, another problem come out: How do I "enable" the menu item after I close the child form I mean, I can limit the child form to pop up once, but how do I "activate" the menu item after the ChildForm_Closed
Thanks
vb_sagacious
First I declare
Private ActiveOpenForm As Form
Then in the procedure
dim bIsActive as boolean=false
For Each frm In Me.MdiChildren
If frm Is ActiveDocForm Then
'make it the active form
bIsActive = true
exit for
End If
next
if bIsActive = false
then open a new one
WinFXGuy
Pin
Windows Forms FAQ
32.4 How do I check to see if a child form is already displayed so I don't have two instances showing
http://www.syncfusion.com/FAQ/WinForms/FAQ_c4c.asp#q521q
_StevenB_
override the child_form's onclose event.
Have it access the parent_form via me.mdiparent (vb.net) from this, you can access any friend function/sub/property/etc by typing this generic form object, to the same class as your parent form. Then after the mdiparent is typed to your parent_form type, just call the sub that does the "enabling" of the menu.
(vb.net ex: ctype(me.mdiparent, frmMain).subToEnableMenus )