Back to Devexpress

CustomDrawEventArgs.Appearance Property

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-customdraweventargs.md

latest7.2 KB
Original Source

CustomDrawEventArgs.Appearance Property

Gets the painted element’s appearance settings.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
public virtual AppearanceObject Appearance { get; }
vb
Public Overridable ReadOnly Property Appearance As AppearanceObject

Property Value

TypeDescription
AppearanceObject

A AppearanceObject object specifying the painted element’s appearance settings.

|

Remarks

Each element within a View is painted using specific appearance settings (background and foreground colors, gradient mode, font, text alignment, etc). Appearance settings in the Grid Control are represented by AppearanceObject objects.

The Appearance property can be used in a number of ways:

  • Read the Appearance property’s attributes to custom paint an element using the default settings. In this case, you should set the CustomDrawEventArgs.Handled property to true to stop the default painting mechanism from clearing your paintings.
  • Change specific attributes of the Appearance property and leave the CustomDrawEventArgs.Handled property set to false. This forces the View to paint the element using the default painting mechanism, but with the modified style settings.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Appearance 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-grid-highlight-cell-values-matching-text-in-autofilterrow/CS/CarsGridWinApp15/Main.cs#L38

csharp
e.Appearance.FillRectangle(e.Cache, e.Bounds);
e.Cache.Paint.DrawMultiColorString(e.Cache, e.Bounds, e.DisplayText, filterCellText, e.Appearance, Color.Black, Color.Gold, false, filterTextIndex);
e.Handled = true;

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

csharp
textRect.Offset(e.Bounds.X, e.Bounds.Y);
EditorButtonObjectInfoArgs args = new EditorButtonObjectInfoArgs(e.Cache, info.Item.Buttons[0], e.Appearance);
Rectangle minBounds = info.EditorButtonPainter.CalcObjectMinBounds(args);

winforms-grid-draw-thick-border-abound-focused-cell/CS/Form1.cs#L132

csharp
e.Appearance.FillRectangle(e.Cache, e.Bounds);
    ((IViewController)view.GridControl).EditorHelper.DrawCellEdit(new GridViewDrawArgs(e.Cache, (view.GetViewInfo() as GridViewInfo), e.Bounds), (e.Cell as GridCellInfo).Editor, (e.Cell as GridCellInfo).ViewInfo, e.Appearance, (e.Cell as GridCellInfo).CellValueRect.Location);
}

winforms-grid-change-color-of-highlighted-search-results/CS/WindowsApplication3/Main.cs#L32

csharp
e.Cache.Paint.DrawMultiColorString(e.Cache, e.Bounds, e.DisplayText, cellInfo.ViewInfo.MatchedRanges,
e.Appearance, e.Appearance.GetStringFormat(), Color.Indigo, Color.LightSlateGray, true);
e.Handled = true;

winforms-grid-highlight-cell-values-matching-text-in-autofilterrow/VB/CarsGridWinApp15/Main.vb#L29

vb
e.Appearance.FillRectangle(e.Cache, e.Bounds)
e.Cache.Paint.DrawMultiColorString(e.Cache, e.Bounds, e.DisplayText, filterCellText, e.Appearance, Color.Black, Color.Gold, False, filterTextIndex)
e.Handled = True

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

vb
textRect.Offset(e.Bounds.X, e.Bounds.Y)
Dim args As New EditorButtonObjectInfoArgs(e.Cache, info.Item.Buttons(0), e.Appearance)
Dim minBounds As Rectangle = info.EditorButtonPainter.CalcObjectMinBounds(args)

winforms-grid-draw-thick-border-abound-focused-cell/VB/Form1.vb#L136

vb
e.Appearance.FillRectangle(e.Cache, e.Bounds)
    CType(view.GridControl, IViewController).EditorHelper.DrawCellEdit(New GridViewDrawArgs(e.Cache, (TryCast(view.GetViewInfo(), GridViewInfo)), e.Bounds), (TryCast(e.Cell, GridCellInfo)).Editor, (TryCast(e.Cell, GridCellInfo)).ViewInfo, e.Appearance, (TryCast(e.Cell, GridCellInfo)).CellValueRect.Location)
End Sub

winforms-grid-change-color-of-highlighted-search-results/VB/WindowsApplication3/Main.vb#L33

vb
e.Appearance.FillRectangle(e.Cache, e.Bounds)
e.Cache.Paint.DrawMultiColorString(e.Cache, e.Bounds, e.DisplayText, cellInfo.ViewInfo.MatchedRanges, e.Appearance, e.Appearance.GetStringFormat(), Color.Indigo, Color.LightSlateGray, True)
e.Handled = True

See Also

Handled

Custom Painting Basics

CustomDrawEventArgs Class

CustomDrawEventArgs Members

DevExpress.XtraGrid.Views.Base Namespace