22 Votes

Delphi/Lazarus: Show Separator Line in Menu

Question by Guest | Last update on 2022-04-18 | Created on 2016-09-27

In some applications, I have seen, that sometimes, individual menu items are separated from each other with some kind of dividing line. This is often used, for example for grouping some menu items belonging together thematically.

However, I have never seen the possibility to set or create such a divider using Delphi or Lazarus. I have searched the object inspector for options for both, the MainMenu (TMainMenu) as well as the PopupMenu (TPopUpMenu).

ReplyPositiveNegative
2Best Answer2 Votes

Indeed, there is not a real "option" for this available, you just have to know the trick:

For creating a separator line, you have to set the caption of the corresponding menu item to "-". As soon as the caption is only consisting of a hyphen, when starting the application, a menu divider is created thereof.

MenuItem1.Caption := 'Item before Divider';
MenuItem2.Caption := '-';
MenuItem3.Caption := 'Item after Divider';

Here is a small example showing this behavior: MenuItem2 is becoming the separator, the items before and after are displayed with their normal caption.
Last update on 2022-04-18 | Created on 2016-09-28

ReplyPositive Negative
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.