windowsforms-devexpress-dot-utils-dot-appearanceobject-dot-getforebrush-x28-devexpress-dot-utils-dot-drawing-dot-graphicscache-x29.md
Gets the solid brush whose color is specified by the AppearanceObject.ForeColor property.
Namespace : DevExpress.Utils
Assembly : DevExpress.Utils.v25.2.dll
NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core
public Brush GetForeBrush(
GraphicsCache cache
)
Public Function GetForeBrush(
cache As GraphicsCache
) As Brush
| Name | Type | Description |
|---|---|---|
| cache | GraphicsCache |
A GraphicsCache object that provides access to the pens and brushes used for painting.
|
| Type | Description |
|---|---|
| Brush |
A Brush descendant representing a brush specified by the appearance object’s settings.
|
If the cache parameter’s value is not a null reference, the GetForeBrush method uses the GraphicsCache object to obtain the solid brush whose color is specified by the foreground color settings of the current appearance object. This lets you obtain the brush more quickly, since it may already be stored within the cache. Otherwise, a new System.Drawing.SolidBrush object with appropriate settings is created and returned.
Use the AppearanceOptions.UseForeColor to obtain the foreground color specified by the appearance object’s settings.
The following code snippets (auto-collected from DevExpress Examples) contain references to the GetForeBrush(GraphicsCache) 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.
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-grid-show-editor-buttons-on-cell-hover/CS/WindowsApplication3/Form1.cs#L48
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/CS/WindowsApplication1/Custom Form Painter/CustomFormPainter.cs#L43
DrawTextShadow(cache, appearance, r);
cache.DrawString(text, appearance.Font, appearance.GetForeBrush(cache), r, appearance.GetStringFormat());
}
if (rect.IsEmpty) return;
Brush br = app.GetForeBrush(cache);
if (isHot)
winforms-grid-display-custom-rows/CS/CustomRowInGrid/CustomRowInGrid/BlankItem.cs#L40
drawRect.Inflate(-3, -3);
e.Cache.DrawString(Text, gri.Appearance.Font, gri.Appearance.GetForeBrush(e.Cache), drawRect, gri.Appearance.GetStringFormat());
}
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
winforms-grid-show-editor-buttons-on-cell-hover/VB/WindowsApplication3/Form1.vb#L51
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
DrawTextShadow(cache, appearance, r)
cache.DrawString(text, appearance.Font, appearance.GetForeBrush(cache), r, appearance.GetStringFormat())
End Sub
If rect.IsEmpty Then Return
Dim br As Brush = app.GetForeBrush(cache)
If isHot Then
winforms-grid-display-custom-rows/VB/CustomRowInGrid/BlankItem.vb#L39
drawRect.Inflate(-3, -3)
e.Cache.DrawString(Text, gri.Appearance.Font, gri.Appearance.GetForeBrush(e.Cache), drawRect, gri.Appearance.GetStringFormat())
End Sub
See Also