Link & Group Hints
- 2 minutes to read
The NavBar control provides advanced functionality for controlling the appearance and behavior of its hints.
The NavBar control distinguishes between two types of hints: a group hint and a link hint. To specify the hint text, use the Hint property of a group or an item. The sample code below shows how to do this.
dxNavBar1.Groups[0].Hint := 'Help';
dxNavBar1.Items[0].Hint := 'Contents';
The screenshot below displays a NavBar link hint.
An alternative way to define group and/or link hint text is to write the OnGetGroupHint and OnGetLinkHint event handlers. These events provide a parameter specifying the element for which a hint is about to be displayed. You must assign the hint text to the AHint parameter. The sample code below handles both events to display elements’ captions as their hints.
procedure TForm1.dxNavBar1GetGroupHint(Sender: TObject;
AGroup: TdxNavBarGroup; var AHint: string);
begin
AHint := AGroup.Caption;
end;
procedure TForm1.dxNavBar1GetLinkHint(Sender: TObject;
ALink: TdxNavBarItemLink; var AHint: string);
begin
AHint := ALink.Item.Caption;
end;
Note, that to be able to display hints in the NavBar control, the OptionsBehavior.Common.ShowGroupsHint and/or OptionsBehavior.Common.ShowLinksHint properties should be enabled.
You can specify a custom style for hints. Use the OptionsStyle.CustomStyles.Hint property of the NavBar control for this purpose. First, create a custom style and modify its properties as your needs dictate. Next, assign this style to the OptionsStyle.CustomStyles.Hint property. The image below displays a hint with a custom style assigned.
The NavBar control lets you display anything you like within hints, by handling the OnCustomDraw.GroupHint and OnCustomDraw.LinkHint events. Note that you might need to change the bounds of hints in order to accommodate the desired information. The OnCalcGroupHintRect and OnCalcLinkHintRect events enable you to do this. Please refer to the Hints Custom Painting topic for details about changing hint dimensions and custom painting of hints.
Note
To provide centralized control over the appearance and behavior of hints in your application or form, use the TcxHintStyleController component shipped with the ExpressEditors Library.