Back to Devexpress

BarItem.OwnFont Property

windowsforms-devexpress-dot-xtrabars-dot-baritem-790bb7bd.md

latest4.7 KB
Original Source

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.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[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; }
vb
<DXCategory("Appearance")>
<Obsolete("Use the Appearance.Font property to specify the item's font.")>
<Browsable(False)>
<EditorBrowsable(EditorBrowsableState.Never)>
Public Overridable Property OwnFont As Font

Property Value

TypeDescription
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.

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

Appearance

ItemsFont

BarItem Class

BarItem Members

DevExpress.XtraBars Namespace