Back to Devexpress

CustomDrawEventArgs.Graphics Property

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

latest4.5 KB
Original Source

CustomDrawEventArgs.Graphics Property

A GDI+ drawing surface. Use the CustomDrawEventArgs.Cache property instead if you enable the DirectX hardware acceleration.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
public Graphics Graphics { get; }
vb
Public ReadOnly Property Graphics As Graphics

Property Value

TypeDescription
Graphics

A Graphics object providing a means for painting.

|

Remarks

The Graphics property returns an object representing the painting surface and providing a means to paint. When custom painting, you can use methods and properties of this object to paint text, graphics primitives and images. Note that painted elements must reside within the area specified by the CustomDrawEventArgs.Bounds property. Otherwise, they will overlap other elements within the control.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Graphics 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-enable-editing-in-group-row-to-change-cell-values/CS/WindowsApplication3/GroupEditProvider.cs#L209

csharp
editViewInfo.Bounds = HotTrackRectangle;
editViewInfo.CalcViewInfo(e.Graphics);
e.Cache.FillRectangle(viewInfo.PaintAppearance.Row.GetBackBrush(e.Cache), HotTrackRectangle);

winforms-grid-display-editors-in-columns-headers/CS/WindowsApplication1/InplaceEditorHelper/DrawEditorHelper.cs#L42

csharp
Rectangle targetRect = GetEditorBounds(e.Bounds, rightIndent);
    DrawEdit(e.Graphics, item, targetRect, value);
}

winforms-grid-enable-editing-in-group-row-to-change-cell-values/VB/WindowsApplication3/GroupEditProvider.vb#L198

vb
editViewInfo.Bounds = HotTrackRectangle
editViewInfo.CalcViewInfo(e.Graphics)
e.Cache.FillRectangle(viewInfo.PaintAppearance.Row.GetBackBrush(e.Cache), HotTrackRectangle)

winforms-grid-display-editors-in-columns-headers/VB/InplaceEditorHelper/DrawEditorHelper.vb#L40

vb
Dim targetRect As Rectangle = GetEditorBounds(e.Bounds, rightIndent)
    DrawEdit(e.Graphics, item, targetRect, value)
End Sub

See Also

Bounds

CustomDrawEventArgs Class

CustomDrawEventArgs Members

DevExpress.XtraGrid.Views.Base Namespace