Vcl.Menus.TMenuItem.GroupIndex

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

property GroupIndex: Byte read FGroupIndex write SetGroupIndex default 0;

C++

__property System::Byte GroupIndex = {read=FGroupIndex, write=SetGroupIndex, default=0};

Properties

Type Visibility Source Unit Parent
property published
Vcl.Menus.pas
Vcl.Menus.hpp
Vcl.Menus TMenuItem

Description

Identifies the logical group to which the menu item belongs.

Use GroupIndex to control how menus are merged. In applications that contain multiple forms, items from the menus of secondary forms can be merged into the application's main menu as those forms become active. MDI applications always merge the menus of child windows with the main menu of the parent window.

By default, all menu items in a menu bar (main menu) have the same GroupIndex value. To use GroupIndex to merge menus, set the GroupIndex value of each successive menu item to a value equal to or greater than that of the previous menu item.

When a menu item in a menu bar that is merged into the application's main menu has the same GroupIndex value as a menu item in the main menu, the menu item in the application's main menu is replaced by the corresponding menu item. If multiple menu items in the application's main menu have the same GroupIndex value, they can be replaced only by separate menu items from the other form's menu that also have repeated GroupIndex values. Thus, the first main menu item with a given value is replaced by the first item in the second form with that value, the second item in the main form is replaced by the second item in the second form, and so on.

When a menu item in a menu bar that is merged into the application's main menu has a GroupIndex that falls between the GroupIndex values of two adjacent items on the application's main menu, that menu item is inserted between the two adjacent items. If the item's GroupIndex value is greater than all other GroupIndex values in the application's main menu, the item appears at the end of the main menu. If the GroupIndex value is less than all other GroupIndex values in the application's main menu, the menu item appears at the beginning of the main menu bar.

When an object created by an OLE 2.0 server application is activated, the server can try to merge its menus with the menus of the container application. The GroupIndex property is used to replace up to three main menu items with items from the server, in the manner described above. The server application uses the following predefined GroupIndex values to locate menu items to replace:



Group Index Description

Edit

1

Server menu items for editing the active OLE object

View

3

Server menu items for modifying the view of the OLE object.

Help

5

Server menu items for accessing the server's online Help.



Note: See the documentation for the OLE server for information about whether it attempts menu merge during in-place activation.

GroupIndex can also be used to define groups of menu items that act like radio buttons. To allow menu items to behave like radio buttons, set the RadioItem property to all menu items in the group to true, and assign each menu item the same value of GroupIndex. Checking any menu item in the group will then uncheck the others.

See Also