delphic++buildertaction

Use TAction for an "icon only" TButton


I have a TAction that is used for both a menu item and a TButton. I want the menu item to show the label, and the TButton to show only the icon. However, when an Action is assigned, Vcl automatically sets the TButton's Caption attribute, and I cannot get rid of it.

Any ideas?


Solution

  • On the menu item, set ImageIndex to -1. On the button, set the Caption to ''. You must do this at runtime.

    This will break the association with the action for just those individual properties. The action will still be used for Hint, OnExecute, OnUpdate etc.