on 09-15-2014 4:51 PM
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?
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.