cancel
Showing results for 
Search instead for 
Did you mean: 

how to traverse a menu?

Former Member
0 Kudos

Suppose I have a menu: m_mymenu. there is a many menuitems for this menu, I want to go through each item in this menu.

How to loop through the whole menu item without hardcode for level of submenuitem?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Here is recursive function which triggers a menuite Clicked event with a given menu Text :

public integer wf_trig_menuitem(string as_menu, menu am_menu)

menu lm_menu, lm_submenu

int li =1

FOR li=1 to upperbound(am_menu.item)

  lm_menu = am_menu.item[li]

  IF lm_menu.text = as_menu then

    lm_menu.Event Clicked()

    return 1

END IF

  wf_trig_menuitem (as_menu, lm_menu)

NEXT 

return 1

//-------------Example

if you want to trigger the Clicked event of the 'Close' item menu from a commandbutton, call the function as the following :

wf_trig_menuitem("Close", parent.menuId)

Hope this helps.

Abdallah.

Former Member
0 Kudos

Hi Kent;

  The MENU object class is actually a collection of Menu Items at the top level. You can access these using the Menu's Item [] array. Each Menu Item also may have subordinate Menu Items - again pointed to by the Item[] array.

  Thus, in order to loop through all the menu items, you would have to use the Item[] array and walk through each array of the array of the array .. etc (basically a B-Tree structure).

HTH

Regards ... Chris