CustomDefaultMenuItem: String;
None
The CustomDefaultMenuItem property returns name of the new context menu command of the ribbon.
If the property value is not set, the new context menu command is not displayed.
Executing the example requires that the repository contains a form with two Button components named Button1 and Button2, and the Ribbon component named Ribbon1. The Ribbon component is populated with two RibbonCategory components named RibbonCategory1 and RibbonCategory2, each of which contains the RibbonPanel component named RibbonPanel1 and RibbonPanel2. The component named RibbonPanel1 contains the RibbonButton component named RibbonButton1.
The CustomDefaultMenuItem property of the Ribbon component is set to Set Up Ribbon value.
Add a link to the Ui system assembly.
The example is a handler of the OnClick events for the components named Button1 and Button2 and the OnCustomDefaultMenuItem events for the component named Ribbon1.
// Add a button to other tab
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Begin
RibbonPanel2.AddReferenceElement(RibbonButton1);
End Sub Button1OnClick;
// Change button names
Sub Button2OnClick(Sender: Object; Args: IMouseEventArgs);
Begin
RibbonButton1.Text := "New text";
End Sub Button2OnClick;
// Display message on selecting new context menu command
Sub Ribbon1OnClickCustomDefaultMenuItem(Sender: Object; Args: IEventArgs);
Begin
WinApplication.InformationBox("OnClickCustomDefaultMenuItem");
End Sub Ribbon1OnClickCustomDefaultMenuItem;
After executing the example:
When the ribbon context menu is opened, the command specified as a value of the CustomDefaultMenuItem property is displayed. The message is displayed on executing the command.
Clicking the Button1 button adds a button that is reference to the button in the component named RibbonPanel1 to the RibbonPanel2 component. The added button depends on the state of the button, to which its refers.
Clicking the Button2 button replaces names of both buttons with the value specified in the event handler, as "New text".
See also: