windowsforms-devexpress-dot-xtrabars-dot-barmanager-1495a441.md
Fires immediately after the highlighted link has been changed.
Namespace : DevExpress.XtraBars
Assembly : DevExpress.XtraBars.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DXCategory("Events")]
public event HighlightedLinkChangedEventHandler HighlightedLinkChanged
<DXCategory("Events")>
Public Event HighlightedLinkChanged As HighlightedLinkChangedEventHandler
The HighlightedLinkChanged event's data class is HighlightedLinkChangedEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Link | Gets the currently highlighted link. |
| PrevLink | Gets the previously highlighted link. |
Write a HighlightedLinkChanged event handler to perform specific actions each time the currently highlighted link is changed. The event parameter allows you to determine the previous and currently highlighted link. Note that this event fires when none of links was previously highlighted or when none of them becomes highlighted. The properties representing the currently and previously highlighted links can return null references in such cases.
If you want to determine the currently highlighted link directly from your code, use the BarManager.HighlightedLink property.
The following example highlights the hovered bar item with bold font.
Bold and Regular.BarManager.HighlightedLinkChanged event. Use e.Link and e.PrevLink parameters to switch fonts.using DevExpress.XtraBars;
namespace Highlight-Hovered-BarItem {
public partial class Form1 : DevExpress.XtraEditors.XtraForm {
Font boldFont;
Font regularFont;
public Form1() {
InitializeComponent();
boldFont = new Font(barManager1.GetController().AppearancesBar.ItemsFont, FontStyle.Bold);
regularFont = new Font(barManager1.GetController().AppearancesBar.ItemsFont, FontStyle.Regular);
barManager1.HighlightedLinkChanged += BarManager1_HighlightedLinkChanged;
}
private void BarManager1_HighlightedLinkChanged(object sender, HighlightedLinkChangedEventArgs e) {
if (e.PrevLink != null && e.PrevLink.Bar == barBrowser)
e.PrevLink.Item.ItemAppearance.SetFont(regularFont);
if (e.Link != null && e.Link.Bar == barBrowser)
e.Link.Item.ItemAppearance.SetFont(boldFont);
}
}
}
Imports DevExpress.XtraBars
Namespace Highlight-Hovered-BarItem
Partial Public Class Form1
Inherits DevExpress.XtraEditors.XtraForm
Private boldFont As Font
Private regularFont As Font
Public Sub New()
InitializeComponent()
boldFont = New Font(barManager1.GetController().AppearancesBar.ItemsFont, FontStyle.Bold)
regularFont = New Font(barManager1.GetController().AppearancesBar.ItemsFont, FontStyle.Regular)
AddHandler barManager1.HighlightedLinkChanged, AddressOf BarManager1_HighlightedLinkChanged
End Sub
Private Sub BarManager1_HighlightedLinkChanged(ByVal sender As Object, ByVal e As HighlightedLinkChangedEventArgs)
If e.PrevLink IsNot Nothing AndAlso e.PrevLink.Bar = barBrowser Then
e.PrevLink.Item.ItemAppearance.SetFont(regularFont)
End If
If e.Link IsNot Nothing AndAlso e.Link.Bar = barBrowser Then
e.Link.Item.ItemAppearance.SetFont(boldFont)
End If
End Sub
End Class
End Namespace
See Also