windowsforms-devexpress-dot-utils-dot-appearanceobject-4cd5a89c.md
Gets or sets the font used to paint the text.
Namespace : DevExpress.Utils
Assembly : DevExpress.Utils.v25.2.dll
NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core
[XtraSerializableProperty]
[DXCategory("Font")]
public virtual Font Font { get; set; }
<XtraSerializableProperty>
<DXCategory("Font")>
Public Overridable Property Font As Font
| Type | Description |
|---|---|
| Font |
A Font object specifying the font used to display the contents of elements.
|
The following example specifies custom fonts and font settings of a simple button and grid columns:
using System.Drawing;
namespace DXApplication {
public partial class Form1 : DevExpress.XtraEditors.XtraForm {
public Form1() {
InitializeComponent();
simpleButton1.Appearance.Font = new Font("Arial", 12, FontStyle.Bold);
gridColumn1.AppearanceHeader.Font = new Font("Courier New", 14, FontStyle.Bold);
gridColumn1.AppearanceCell.Font = new Font("Courier New", 10, FontStyle.Bold);
gridColumn2.AppearanceHeader.Font = new Font("Times New Roman", 14, FontStyle.Underline);
gridColumn2.AppearanceCell.Font = new Font("Times New Roman", 10, FontStyle.Underline);
gridView1.OptionsView.ColumnHeaderAutoHeight = DevExpress.Utils.DefaultBoolean.True;
}
}
}
Imports System.Drawing
Namespace DXApplication
Partial Public Class Form1
Inherits DevExpress.XtraEditors.XtraForm
Public Sub New()
InitializeComponent()
simpleButton1.Appearance.Font = New Font("Arial", 12, FontStyle.Bold)
gridColumn1.AppearanceHeader.Font = New Font("Courier New", 14, FontStyle.Bold)
gridColumn1.AppearanceCell.Font = New Font("Courier New", 10, FontStyle.Bold)
gridColumn2.AppearanceHeader.Font = New Font("Times New Roman", 14, FontStyle.Underline)
gridColumn2.AppearanceCell.Font = New Font("Times New Roman", 10, FontStyle.Underline)
gridView1.OptionsView.ColumnHeaderAutoHeight = DevExpress.Utils.DefaultBoolean.True
End Sub
End Class
End Namespace
DevExpress WinForms controls use the “Tahoma” font as the default font. Use the following properties to change the default font used by DevExpress controls in your application:
Read the following topic for additional information: Default Application Font.
Setting the Font property to the control’s default font (which is currently used by the user’s operating system) automatically sets the appearance object’s AppearanceOptions.UseFont property to false. If the UseFont property is set to false and the current Appearance object has a parent Appearance object, the Appearance object uses the parent’s font settings.
Use the AppearanceObject.GetFont method to obtain the font settings specified by the appearance object’s settings.
Read the following topics for additional information:
The following code snippets (auto-collected from DevExpress Examples) contain references to the Font property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-listbox-item-templates-enable-word-wrap/CS/S131055/Form1.cs#L45
e.Appearance.DrawBackground(e.Cache, e.Bounds);
TextUtils.DrawString(e.Graphics, control.GetItemText(e.Index), control.Appearance.Font,
control.Appearance.ForeColor, e.Bounds);
AppearanceObject appearance = new AppearanceObject();
appearance.Font=new Font(FontFamily.GenericSansSerif, 10F, FontStyle.Underline);
((RepositoryItemLookupEdit)item).Buttons.Add(new EditorButton(ButtonPredefines.Glyph, "Edit", -1, true, true, true, HorzAlignment.Default, null, new KeyShortcut(System.Windows.Forms.Keys.Enter), appearance, "Press this button to edit the object"));
e.DefaultDraw();
e.Cache.DrawString(validationError, e.Appearance.Font, e.Cache.GetSolidBrush(Color.Black), e.Bounds);
e.Handled = true;
winforms-calendar-dateedit-cell-appearance-customization/CS/Calendar_CellStyleProvider/Form1.cs#L67
if(font == null) {
font = new Font(cell.Appearance.Font, System.Drawing.FontStyle.Bold);
}
winforms-grid-highlight-modified-cells/CS/Form1.cs#L35
e.Appearance.BackColor2 = Color.LimeGreen;
e.Appearance.Font = new Font(e.Appearance.Font, FontStyle.Bold);
}
winforms-listbox-item-templates-enable-word-wrap/VB/S131055/Form1.vb#L44
e.Appearance.DrawBackground(e.Cache, e.Bounds)
TextUtils.DrawString(e.Graphics, control.GetItemText(e.Index), control.Appearance.Font, control.Appearance.ForeColor, e.Bounds)
e.Handled = True
e.DefaultDraw()
e.Cache.DrawString(validationError, e.Appearance.Font, e.Cache.GetSolidBrush(Color.Black), e.Bounds)
e.Handled = True
winforms-calendar-dateedit-cell-appearance-customization/VB/Calendar_CellStyleProvider/Form1.vb#L82
If font Is Nothing Then
font = New Font(cell.Appearance.Font, FontStyle.Bold)
End If
winforms-grid-highlight-modified-cells/VB/Form1.vb#L37
e.Appearance.BackColor2 = Color.LimeGreen
e.Appearance.Font = New Font(e.Appearance.Font, FontStyle.Bold)
End If
Dim captionColor As Color = EditorsSkins.GetSkin(viewInfo.LookAndFeel.ActiveLookAndFeel)(EditorsSkins.SkinEditorButton).Color.GetForeColor()
info.Cache.DrawString(str_value, viewInfo.Appearance.Font, New SolidBrush(captionColor), info.Bounds, info.Appearance.GetStringFormat())
Return
See Also