[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Menus' (#lcl)

# NewSubMenu

Creates and configures a new sub-menu with the specified child menu items.

## Declaration

Source position: menus.pp line 512

`function NewSubMenu(`
`const ACaption: string;`
`hCtx: THelpContext;`
`const AName: string;`
`const Items: array of TMenuItem;`
`TheEnabled: Boolean = True`
`):TMenuItem;`

## Arguments

`ACaption` |  | Caption text displayed for the sub-menu.
`hCtx` |  | Help context for the sub-menu.
`AName` |  | Name for the menu item representing the sub-menu.
`Items` |  | Array of menu items for the new sub-menu.
`TheEnabled` |  | True if the menu item for the sub-menu is enabled.

## Function result

TMenuItem with the sub-menu created in the routine.

## Description

NewSubMenu is a TMenuItem function used to create a sub-menu using the values specified in the arguments to the routine. The return value contains the TMenuItem instance created to represent the sub-menu. It uses the value in aCaption as the caption text for the menu item, and AName contains the name for the sub-menu.

The menu item is created using Nil as the owner of the class instance; it must be added or inserted into the Items for the desired menu instance. Each of the menu Items is added to the class instance, and the remaining arguments are assigned to the corresponding properties for the sub-menu (menu item).