Solved

How to find the parent menu item for a given menu item

Posted on 2003-11-25
7
189 Views
Last Modified: 2010-05-03
Hi,

Does anyone know how to get a reference to the parent menu item for a given menu item.
And also, how to get a list or collection of child menu items.

I've tried using the Parent property of a menu object but always refers to the parent form and not the parent menu item for a given sub item.

Any ideas ?

Alan.
0
Comment
Question by:aregan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
7 Comments
 
LVL 9

Expert Comment

by:p_sie
ID: 9817426
Don't think there is a parent property, but I did it as follows:

Name the parent menu-items mnuFile, mnuEdit
And name the child menu-items mnuFileOpen, mnuFileClose etc, mnuEditCut , etc.
This way you created your own stucture

You can make a list of the menu-items this way by

Dim ctl as Control
For each ctl in Form.Controls
    If Left(ctl.Name,3) = "mnu" THEN
           'Menu-item........
           'ctl.Name is the name used in code
           'ctl.Caption is the name by which the menu-item appears in the menu, remember to filter out the & in the Caption
    End If
Next
0
 
LVL 9

Expert Comment

by:p_sie
ID: 9940575
aregan,

is this question still open? I am just checking questions that I participated in and that were not closed yet!

Greetings, p_sie
0
 

Author Comment

by:aregan
ID: 9940789
Thanks P_Sie,

I was hoping that someone would come back with a suggestion on how to figure out the menu heirarchy at run time. BTW - I found using the following a little safer for getting a list of menus.

Dim ctl as Control
For each ctl in Form.Controls
    If TypeOf ctrl is Menu THEN
           'Menu-item........
           'ctl.Name is the name used in code
           'ctl.Caption is the name by which the menu-item appears in the menu, remember to filter out the & in the Caption
    End If
Next

Thanks,

Alan
0
 
LVL 9

Expert Comment

by:p_sie
ID: 9940796
That's maybe a better solution.
Good luck
0
 

Accepted Solution

by:
amp072397 earned 0 total points
ID: 10618832
PAQed, with points refunded (20)

Thanks very much!
amp, ee admin, amp*at*experts-exchange.com
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question