1
1
Fork 0
mirror of https://github.com/FellippeHeitor/InForm.git synced 2024-05-12 06:50:12 +00:00
6 Menus
Fellippe Heitor edited this page 2021-12-22 12:12:15 -03:00

MenuBar and MenuItem controls provide an easy way to add a menu system to your program.

To add a new MenuBar item, either go to Insert menu and choose "Menu Bar" or right-click your form and choose "Add menu bar control". After the menu bar has been created, you can continue adding new items directly on the preview, by clicking the empty space next to the last menu bar item.

To add a new Menu Item, go to Insert menu and choose "Menu Item". You can also add new items directly on the preview, by clicking the empty space in the menu panel.

Menus fonts and colors are based on the main form, so they will change accordingly when you edit the main form's font and color properties.

Techniques

  • Add hot-key shortcuts using the SetCaption (or at design time in the Editor) by adding an ampersand before the desired letter ("&File", "E&xit").
  • Add a separator by finishing the item before the desired separator position with a hyphen ("Save &as...-")
  • Menu items can have an icon (must be a regular image, not an .ico file though). Just select the "Image file" property in the editor and enter an image file name. It'll be instantly loaded and shown. (in code you must use the LoadImage method).
  • Menu items can be checked. Just set the Value property to True.
  • Menu items can be grouped and have bullets (like RadioButton controls). Set the MarkerStyle to Bullet (from CheckMark) and set the value to true. ** If a menu item contains an image icon, it'll not be shown when the item is "checked", so these are mutually exclusive properties.
  • The last menu item can be aligned to the right on the menu bar. Just select it and choose "Right" in the "Text align" drop-down list.
  • After you've added a menu item or menu bar item you can reorder them by changing their z-order (Edit->Z-ordering).

To change the value of a MenuItem control that has been created with the bullets style to True at runtime, use the SetRadioButtonValue method, as that'll make sure to properly set the other MenuItem controls in the same group to False first:

SetRadioButtonValue ControlID

Events

Methods

Properties editable at runtime