Skip to main content
Bar

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

BarItem.OwnFont Property

OBSOLETE

Use the Appearance.Font property to specify the item's font.

Specifies the font used to display the captions of links corresponding to this item.

Namespace: DevExpress.XtraBars

Assembly: DevExpress.XtraBars.v24.2.dll

NuGet Package: DevExpress.Win.Navigation

#Declaration

[Browsable(false)]
[DXCategory("Appearance")]
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("Use the Appearance.Font property to specify the item's font.")]
public virtual Font OwnFont { get; set; }

#Property Value

Type Description
Font

A System.Drawing.Font object that specifies the font used to display the captions of associated links.

#Remarks

The OwnFont property is synchronized with the Font attribute of the BarItem.ItemAppearance property.

When you assign a font to the Appearance.Font property, the Appearance.Options.UseFont option is automatically enabled. So, the assigned font is immediately applied to the item’s links. You can turn off the Appearance.Options.UseFont option to temporarily disable the item’s font.

If no font is assigned to the Appearance.Font property or the item’s font is disabled, the default font is used (see the BarManagerAppearances.ItemsFont topic, to learn more).

#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