Back to Devexpress

AppearanceObject.GetStringFormat() Method

windowsforms-devexpress-dot-utils-dot-appearanceobject-9388a929.md

latest6.8 KB
Original Source

AppearanceObject.GetStringFormat() Method

Gets the formatting attributes specified by the appearance object’s settings.

Namespace : DevExpress.Utils

Assembly : DevExpress.Utils.v25.2.dll

NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core

Declaration

csharp
public StringFormat GetStringFormat()
vb
Public Function GetStringFormat As StringFormat

Returns

TypeDescription
StringFormat

A StringFormat object which specifies formatting attributes, such as the line spacing and alignment.

|

Remarks

The formatting attributes are specified by the text options which can be accessed via the AppearanceObject.TextOptions property.

The following code snippets (auto-collected from DevExpress Examples) contain references to the GetStringFormat() method.

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-custom-buttonedit-display-editvalue-on-button/CS/TestMyButtonEdit/MyButtonEditPainter.cs#L55

csharp
Color captionColor = 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;

winforms-grid-show-editor-buttons-on-cell-hover/CS/WindowsApplication3/Form1.cs#L48

csharp
info.EditorButtonPainter.DrawObject(args);
e.Cache.DrawString(e.DisplayText, e.Appearance.Font, e.Appearance.GetForeBrush(e.Cache), textRect, e.Appearance.GetStringFormat());
e.Handled = true;

winforms-tabcontrol-paint-tab-header-text-vertically/CS/WindowsFormsApplication907/MySkinTabPainter.cs#L33

csharp
a.GetFont(),Brushes.Green ,
        a.GetStringFormat(), pInfo.Text, angle, hotKeyPrefixOverride);
}

winforms-xtraform-center-caption/CS/WindowsApplication1/Custom Form Painter/CustomFormPainter.cs#L43

csharp
DrawTextShadow(cache, appearance, r);
    cache.DrawString(text, appearance.Font, appearance.GetForeBrush(cache), r, appearance.GetStringFormat());
}

winforms-scheduler-customize-appointment-flyout/CS/CustomAppointmentFlyoutExample/Form1.cs#L52

csharp
GraphicsCache cache = viewInfo.Cache;
StringFormat stringFormat = new StringFormat(viewInfo.View.Appearance.GetStringFormat());
stringFormat.Alignment = stringFormat.LineAlignment = StringAlignment.Center;

winforms-custom-buttonedit-display-editvalue-on-button/VB/TestMyButtonEdit/MyButtonEditPainter.vb#L54

vb
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

winforms-grid-show-editor-buttons-on-cell-hover/VB/WindowsApplication3/Form1.vb#L51

vb
info.EditorButtonPainter.DrawObject(args)
e.Cache.DrawString(e.DisplayText, e.Appearance.Font, e.Appearance.GetForeBrush(e.Cache), textRect, e.Appearance.GetStringFormat())
e.Handled = True

winforms-xtraform-center-caption/VB/WindowsApplication1/Custom Form Painter/CustomFormPainter.vb#L49

vb
DrawTextShadow(cache, appearance, r)
    cache.DrawString(text, appearance.Font, appearance.GetForeBrush(cache), r, appearance.GetStringFormat())
End Sub

winforms-scheduler-customize-appointment-flyout/VB/CustomAppointmentFlyoutExample/Form1.vb#L57

vb
Dim cache As GraphicsCache = viewInfo.Cache
Dim stringFormat As StringFormat = New StringFormat(viewInfo.View.Appearance.GetStringFormat())
stringFormat.LineAlignment = StringAlignment.Center

winforms-pivot-customize-cell/VB/PivotCustomDraw/Form1.vb#L26

vb
r.Inflate(-4, -4)
e.GraphicsCache.DrawString(e.DisplayText, e.Appearance.Font, Brushes.White, r, e.Appearance.GetStringFormat())
e.Handled = True

See Also

TextOptions

Font

AppearanceObject Class

AppearanceObject Members

DevExpress.Utils Namespace