We help IT Professionals succeed at work.

disable sub menu

techi03
techi03 asked
on
223 Views
Last Modified: 2010-05-01
i  created a  mdi application  and merged  the  menus  of the  parent  and  the  child.
i figured out  how  to disable the  main menu of  both
mainmenu1.menuitems(1).enabled.false
but  cannot  find a  way to  disable the  submenus.
i  tried
mainmenu.menuitems(4).enabled=alse
and
mainmenu1.menuitems.item(4).enabled =false
need help
thanx
Comment
Watch Question

Pi7

Commented:
What do you mean by merging the menus of both parent and child?
Have you created a control array for your menu items?
By main menu items do you mean the diffrent menus like: File,Edit, View etc ?
Be clearer

Commented:
Have you tried


Screen.ActiveForm.mainmenu1.menuitems.item(4).enabled =false

Author

Commented:
main  MDI parent  has
File
   New
   Exit

child has
File  
  Add
  Delete

when  the  child  is opened  in  the parent  i have
File
   Add
   Delete
   New
   Exit

what  i  want  is to be able t o  disable/enable  the  Add  and  Delete  submenu

tried the  suggestin  by eddykt  doesnt work
where  do i  write t his
i type  screen.   but i  dont  see activeform  in  the  listbox
in both the parent or  the child.
Thanx


Pi7

Commented:
OK techi03, I tried to do something similar to yours.Only problem is when the child form was opened in mdi form only the sub menus for the child form were displayed.
Check this:

I created menus on both child and parent. Each submenu is referenced by :
mnuitem(Index)
'Form1- child form
'mdiform - parent
' mdi menu: File - New ( name: mnuitem(1)) ,Exit (name:mnuitem(2))
'Form1 menu: - Delete ( name: mnuitem(1)), Add(name:mnuitem(2))
startup form is mdi
----------------------------------------------------------------------------------------------------

Private MDIForm_Load()
' open child menu in parent
Form1.Show ' displays Form1 menu only , mdi menu does not show
'disables second submenu i.e. Add
Me.ActiveForm.mnuitem(2).Enabled = False
End Sub
------------------------------------------------------------------------------------------------------
may be you should tell me how you got all the sub menus to show but the above works fine
Let me know how this does or does not help

Bye
 

Commented:
If you use Me.ActiveForm then you can only access from mdi parent form.

USe Screen.ActiveForm can access from anywhere from your program

Author

Commented:
tried the above suggestion doesnt work:(
from the mdi parent
Me.ActiveForm.Menu.MenuItems(3).Enabled = False

to merge both menus:
u will notice when u open the child form its menu gets added to the parents menu so if u had a
File
 new
in the main

and a

File
 add
in the parent
then u would have
File File
in the parent, when the child is opened
to merge select the childs File in the properties >>MergeType=mergeItems
then click Add go to properties >>MergeType = Add
Pi7

Commented:
tried to follow your steps on merging but couldn't do it.Could ou be more explanatory?

Author

Commented:
i fugured it out
all i had to do was menuitem(7).enabled = false
no need for this manu1.menuitem(7).enabled=false
Pi7

Commented:
Good you figured it out. So how does your code look like now? and if you could also be clearer on how you merged both menus; it's interesting to know how, because what I know is in a case where both child and parent have menus,only the child menu is displayed when the child form is opened in the parent

Regards,
Pi7

Author

Commented:
to  merge the menus
set the  child  and  parents  menus  to  mergeitems
and  its mergeorder  to  99 <-- this will add  it  to the  bottom  of  the new  list.
set the merge type of  the childs menu  items  to  add. (e.g  edit -  add -  close)
thats about  it
to disable  the  child menu items
menuitem(number).enabled  =false

hope  this  helps  others
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.