Skip to main content
Bar

BarManager.HighlightedLinkChanged Event

Fires immediately after the highlighted link has been changed.

Namespace: DevExpress.XtraBars

Assembly: DevExpress.XtraBars.v25.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[DXCategory("Events")]
public event HighlightedLinkChangedEventHandler HighlightedLinkChanged

Event Data

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.

Remarks

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.

Example

The following example highlights the hovered bar item with bold font.

  1. Create two fonts with different font styles - Bold and Regular.
  2. Handle the BarManager.HighlightedLinkChanged event. Use e.Link and e.PrevLink parameters to switch fonts.

LinkFont - OwnFont

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);
    }
  }
}
See Also