I have a mainmenu on my Form and I want to be able to insert separator to it programmatically not during design time. I went through context popup menu for the mainmenu that lists all the available properties and did not find anything that will allow me to insert separator. Google wasn't much of a help. So, how is this done in Delphi on Windows? I am using Delphi 2010.
I simply want to do something like the following but AddSeparator command doesn't exist:
MainMenu1.Items[5].AddSeparator;
Create a new menu item and set its caption to '-'.
var
MenuItem: TMenuItem;
....
MenuItem := TMenuItem.Create(Menu); // Menu is the menu into which you are adding
MenuItem.Caption := '-';
Menu.Items.Add(MenuItem);
Instead of Add, which adds to the end of the menu, you can use Insert to insert the item into the middle of the menu.
The documentation says:
Specify a hyphen character (-) as the value of Caption for the menu item to indicate that the menu item is a separator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With