Arg81
Well-known member
I thought I'd post this solution, it may come in handy to others. Sorry to those who already know, but I tried searching the forums before working this out for myself (for once!!)
When you have a MDI parent with a MainMenu, it can contain a lot of menuItems. Likewise when you open a child form from one of those menuItems.
I was trying to kill 2 birds with one stone - 1) When a child form is open, I don't want the user to be able to open another form or report that is not specific to the currently opened form.
2) To stop confusion on the merge of menus of parent & child, I wanted to find a way of hiding or disabling the parent menu commands when the child form is open.
I managed to do the above by creating the following on the MDI Parent form. The MenuItems 1,2,3 and 4 are the headers in the menu.
Then when opening the child form;
So with the above code, when the child form opens, it disables the parent menu commands, but the child menu commands are still displayed. But when you close the child form, you want to re-enable those parent form menu commands. I did this by;
Hopefully this will come in handy for newbies like myself, or people wanting a quick solution to the "I don't want to open a 2nd instance of that form" or "menus merged, looks confusing" problems.
Regards,
Luke
When you have a MDI parent with a MainMenu, it can contain a lot of menuItems. Likewise when you open a child form from one of those menuItems.
I was trying to kill 2 birds with one stone - 1) When a child form is open, I don't want the user to be able to open another form or report that is not specific to the currently opened form.
2) To stop confusion on the merge of menus of parent & child, I wanted to find a way of hiding or disabling the parent menu commands when the child form is open.
I managed to do the above by creating the following on the MDI Parent form. The MenuItems 1,2,3 and 4 are the headers in the menu.
VB.NET:
Private Sub MDIMenuActive (byval blnAct as Booleen)
me.MenuItem1.enabled = blnAct
me.MenuItem2.enabled = blnAct
me.MenuItem3.enabled = blnAct
me.MenuItem4.enabled = blnAct
End Sub
Then when opening the child form;
VB.NET:
Private Sub mnuNew_Click (..........) Handles mnuNew.click
dim frm as new frmNewRecordForm
frm.mdiparent = me
frm.show()
me.MDIMenuActive(False)
End Sub
So with the above code, when the child form opens, it disables the parent menu commands, but the child menu commands are still displayed. But when you close the child form, you want to re-enable those parent form menu commands. I did this by;
VB.NET:
Private Sub frmMenu_Got Focus (.......) Handles myBase.GotFocus
me.MDIMenuActive(True)
End Sub
Hopefully this will come in handy for newbies like myself, or people wanting a quick solution to the "I don't want to open a 2nd instance of that form" or "menus merged, looks confusing" problems.
Regards,
Luke