Solved

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

Posted on 2003-11-25
7
186 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

919 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now