Back to Devexpress

AppearanceObject.DrawString(GraphicsCache, String, Rectangle, Brush, StringFormat) Method

windowsforms-devexpress-dot-utils-dot-appearanceobject-dot-drawstring-x28-devexpress-dot-utils-dot-drawing-dot-graphicscache-system-dot-string-system-dot-drawing-dot-rectangle-system-dot-drawing-dot-brush-system-dot-drawing-dot-stringformat-x29.md

latest4.3 KB
Original Source

AppearanceObject.DrawString(GraphicsCache, String, Rectangle, Brush, StringFormat) Method

Draws a text string at the specified position using the specified color and format.

Namespace : DevExpress.Utils

Assembly : DevExpress.Utils.v25.2.dll

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

Declaration

csharp
public virtual void DrawString(
    GraphicsCache cache,
    string text,
    Rectangle bounds,
    Brush foreBrush,
    StringFormat format
)
vb
Public Overridable Sub DrawString(
    cache As GraphicsCache,
    text As String,
    bounds As Rectangle,
    foreBrush As Brush,
    format As StringFormat
)

Parameters

NameTypeDescription
cacheGraphicsCache

A GraphicsCache object providing storage for the pens, fonts and brushes used during painting.

| | text | String |

A String value representing the text to be drawn.

| | bounds | Rectangle |

A Rectangle value representing the drawing area.

| | foreBrush | Brush |

A Brush object which determines the color and texture of the drawn text.

| | format | StringFormat |

A StringFormat object which specifies formatting attributes, such as the line spacing and alignment, that are applied to the drawn text.

|

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the DrawString(GraphicsCache, String, Rectangle, Brush, StringFormat) 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#L42

csharp
bounds = new Rectangle(bounds.X, bounds.Y, text_width, bounds.Height);
    appearance.DrawString(info.Cache, text, bounds, appearance.GetForeBrush(info.Cache), appearance.GetTextOptions().GetStringFormat(info.ViewInfo.DefaultTextOptions));
}

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

vb
bounds = New Rectangle(bounds.X, bounds.Y, text_width, bounds.Height)
    appearance.DrawString(info.Cache, text, bounds, appearance.GetForeBrush(info.Cache), appearance.GetTextOptions().GetStringFormat(info.ViewInfo.DefaultTextOptions))
End Sub

See Also

AppearanceObject Class

AppearanceObject Members

DevExpress.Utils Namespace