This article shares how to use the menu component TMainMenud for your reference. The specific content is as follows
Menu component TMainMenu
To create a menu, double-click TmenuMain and click Caption to add a menu item.
To add a dividing line in the menu, just add "-" to add a dividing line.
Cascading menu design
Right-click the mouse and select the Create Submenu menu item in the pop-up menu.
Radio function design
To select the RadioItem property in the designed menu item, set the Checked property to True
Design of check function
In the design menu item, select the RadioItem property to False and the Checked property to True.
Dynamically create menus
The source code is as follows
procedure TForm1.Button1Click(Sender: TObject);var MainMenu: TMainMenu; MenuItem: TMenuItem;begin //Main menu creation MainMenu:=TMainMenu.Create(self); Self.Menu:=MainMenu; //File menu creationMenuItem:= TMenuItem.Create(MainMenu); MenuItem.Caption:='File'; MainMenu.Items.Add(MenuItem); //Create a new submenuCreateMenuItem:=TMenuItem.Create(MainMenu); MenuItem.Caption:='New'; MainMenu.Items[0].Add(MenuItem); //Submenu Create a submenu in MenuItem:= TMenuItem.Create(MainMenu); MenuItem.Caption:='Open'; MainMenu.Items[0].Items[0].Add(MenuItem); MenuItem:= TMenuItem.Create(MainMenu); MenuItem.Caption:='Save'; MainMenu.Items[0 ].Items[0].Add(MenuItem);end;end.
Add icon to main menu
To add an icon to the menu, first use the TImagaList component to specify the icon for the menu, set the Images property in the menu to ImageList1, and then select the icon index to be added. As shown in the picture:
The above is the entire content of this article. I hope it will be helpful to everyone's study. I also hope everyone will support Wulin.com.