Skip to main content

How to: Customize Font Settings for Specific Items

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