Back to Devexpress

CustomDrawEventArgs.Bounds Property

windowsforms-devexpress-dot-xtratreelist-dot-customdraweventargs-fc9d3daf.md

latest4.3 KB
Original Source

CustomDrawEventArgs.Bounds Property

Gets the painted element’s bounding rectangle.

Namespace : DevExpress.XtraTreeList

Assembly : DevExpress.XtraTreeList.v25.2.dll

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

Declaration

csharp
public Rectangle Bounds { get; }
vb
Public ReadOnly Property Bounds As Rectangle

Property Value

TypeDescription
Rectangle

A System.Drawing.Rectangle structure specifying the boundaries of the painted element.

|

Remarks

There are two basic things required to paint an object. These are a System.Drawing.Graphics object used to paint and a rectangle specifying the object’s boundaries. When performing custom painting, you can access these values via the CustomDrawEventArgs.Graphics and Bounds properties of the event parameter.

Use the Bounds property to locate painted text, images, etc. inside the painted element’s area.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Bounds 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-dashboard-custom-items-extension/CS/CustomItemExtension/CustomItems/TreeList/TreeListItemControlProvider.cs#L49

csharp
e.DefaultDraw();
e.Cache.DrawString(validationError, e.Appearance.Font, e.Cache.GetSolidBrush(Color.Black), e.Bounds);
e.Handled = true;

winforms-treelist-implement-group-level-style-feature/CS/Q220534/Form1.cs#L26

csharp
Dictionary<int, Rectangle> groupLevelIndentRects = new Dictionary<int, Rectangle>();
CalcGroupLevelIndentRects(tree.ViewInfo, e.Node, e.Bounds, groupLevelIndentRects);
foreach (KeyValuePair<int, Rectangle> kvp in groupLevelIndentRects)

winforms-dashboard-custom-items-extension/VB/CustomItemExtension/CustomItems/TreeList/TreeListItemControlProvider.vb#L55

vb
e.DefaultDraw()
e.Cache.DrawString(validationError, e.Appearance.Font, e.Cache.GetSolidBrush(Color.Black), e.Bounds)
e.Handled = True

winforms-treelist-implement-group-level-style-feature/VB/Q220534/Form1.vb#L24

vb
Dim groupLevelIndentRects As New Dictionary(Of Integer, Rectangle)()
CalcGroupLevelIndentRects(tree.ViewInfo, e.Node, e.Bounds, groupLevelIndentRects)
For Each kvp As KeyValuePair(Of Integer, Rectangle) In groupLevelIndentRects

See Also

Graphics

Appearance

CustomDrawEventArgs Class

CustomDrawEventArgs Members

DevExpress.XtraTreeList Namespace