How to Make an Item Occupy Several Rows within a Ribbon Toolbar
- 2 minutes to read
A Ribbon tab group displays items from the bound toolbar (see the tab group’s Toolbar property). An item’s representation within a tab group depends on the layout constraints specified for each item (see TdxBarItemViewLevels). Some items don’t provide this information. For these items, the layout data is specified in their ancestor – TdxBarItemControl. The default state it returns via a GetPossibleViewLevels method is ivlSmallIconWithText. It means that an item only occupies one row in a tab group. If you need to span a particular item over an entire tab group’s height, override the GetPossibleViewLevels method.
Consider a TdxBarControlContainerItem object as an example. This is a container for any external control to be placed in a toolbar (see the TdxBarControlContainerItem.Control property). By default, this item only resides in one row.
To inform the Ribbon that TdxBarControlContainerItem will take up the entire group’s height for any layout, use the following code:
unit dxBarExtItems.pas
// ...
TdxBarControlContainerControl = class(TdxBarItemControl)
protected
function GetPossibleViewLevels: TdxBarItemViewLevels; override;
// ...
implementation
// ...
function TdxBarControlContainerControl.GetPossibleViewLevels: TdxBarItemViewLevels;
begin
// indicate that this item requires the largest possible space
Result := [ivlLargeIconWithText];
end;
The following image demonstrates the result:
Note that to make these changes come into effect for the C++ Builder, you must run Express Install in the Recompile mode.