CustomDrawEventArgs.DefaultDraw() Method
Performs default painting of an element.
Namespace: DevExpress.XtraGrid.Views.Base
Assembly: DevExpress.XtraGrid.v24.1.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
Declaration
Remarks
The DefaultDraw method can be useful if you need to draw custom information over the default element rendering. To do this, call the DefaultDraw method and then draw custom information using the methods provided by the CustomDrawEventArgs.Graphics object.
The DefaultDraw method automatically sets the CustomDrawEventArgs.Handled property to true to prevent additional default painting from being performed after a custom draw event handler has been completed.
The DefaultDraw method does nothing if the CustomDrawEventArgs.Handled property has already been set to true.
Example
In the sample below, the GridView.CustomDrawCell event is handled to custom-paint data cells.
The CustomDrawEventArgs.DefaultDraw
method applies the default draw to all cells. For all “Units in Stock” cells that display 0, a custom icon is drawn on top of this default cell rendering.
Image warningImage = Image.FromFile("c:\\warning.png");
private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) {
if (e.Column.FieldName == "UnitsInStock") {
e.DefaultDraw();
if (Convert.ToInt32(e.CellValue) == 0)
e.Cache.DrawImage(warningImage, e.Bounds.Location);
}
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the DefaultDraw() 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.