Syntax 7: For RibbonMenu controls
Description
Inserts a menu item at the specified position in a ribbon
menu.
Applies to
Syntax
|
1 |
controlname.InsertItem ({Long ParentIndex, } Long Index, String Text, String PictureName, String Clicked ) |
|
1 |
controlname.InsertItem ({Long ParentIndex, } Long Index, RibbonMenuItem Item ) |
|
Argument |
Description |
|---|---|
|
controlname |
The name of the RibbonMenu control into which you want |
|
ParentIndex |
The index of the menu item (RibbonMenuItem) into which It cannot be an index of a separator (that is |
|
Index |
The index number of the menu item or submenu item before |
|
Text |
The text that displays in the menu item or submenu |
|
PictureName |
The name of the file that contains the picture. The |
|
Clicked |
The name of the Clicked user event to be bound with the |
|
Item |
A RibbonMenuItem item you want to insert. Only |
Return value
Long.
Returns the position of the item if it succeeds and -1 if an error
occurs. If any argument’s value is null, returns null.
Usage
Only menu items with the “Normal” or “Separator” type (that is
RibbonMenuItem with ItemType 0 or 1) can be added to the RibbonMenu
control.
A RibbonMenu control can contain menu items in no more than two
levels.
The user events to be bound with the menu item must be defined
correctly according to the requirements of RibbonMenuItem. For details,
see Clicked in PowerScript Reference and Selected in PowerScript Reference.
Example 1
This example inserts a “MenuItem1” menu item and then inserts two
submenu items “SubMenuItem1” and “SubMenuItem2” under
“MenuItem1”.
|
1 2 3 4 5 6 |
Long ll_Return, ll_Index RibbonMenu lr_Menu ll_Index = lr_Menu.InsertItem (1, "MenuItem1", "AddSmall!", "Ue_MenuItem1Clicked") ll_Return = lr_Menu.InsertItem (ll_Index, 1, "SubMenuItem1", "AddSmall!", "Ue_SubMenuItem1Clicked") ll_Return = lr_Menu.InsertItem (ll_Index, 2, "SubMenuItem2", "AddSmall!", "Ue_SubMenuItem2Clicked") |
Example 2
This example also inserts a “MenuItem1” menu item and then inserts
two submenu items “SubMenuItem1” and “SubMenuItem2” under “MenuItem1”.
It first defines three RibbonMenu items (lr_MenuItem1, lr_SubMenuItem1,
lr_SubMenuItem2) with various properties (including binding with
“Ue_MenuItem1Clicked” and “Ue_MenuItem1Selected” user events), and then
inserts lr_MenuItem1 as the menu item, and lr_SubMenuItem1 and
lr_SubMenuItem2 as the submenu items.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Long ll_Return, ll_Index RibbonMenu lr_Menu RibbonMenuItem lr_MenuItem1, lr_SubMenuItem1, lr_SubMenuItem2 lr_MenuItem1.Text = "MenuItem1" lr_MenuItem1.PictureName = "AddSmall!" lr_MenuItem1.Clicked = "Ue_MenuItem1Clicked" lr_MenuItem1.Selected = "Ue_MenuItem1Selected" lr_SubMenuItem1.Text = "SubMenuItem1" lr_SubMenuItem2.Text = "SubMenuItem2" ll_Index = lr_Menu.InsertItem (1, lr_MenuItem1) ll_Return = lr_Menu.InsertItem (ll_Index, 1, lr_SubMenuItem1) ll_Return = lr_Menu.InsertItem (ll_Index, 2, lr_SubMenuItem2) |
See also