VGridControlBase.CustomDrawRowHeaderIndent Event
Enables row header indents to be painted manually.
Namespace: DevExpress.XtraVerticalGrid
Assembly: DevExpress.XtraVerticalGrid.v24.2.dll
Declaration
Event Data
The CustomDrawRowHeaderIndent event's data class is CustomDrawRowHeaderIndentEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Appearance | Gets the painted element’s appearance settings. Inherited from CustomDrawEventArgs. |
Bounds | Gets a value specifying limits for the drawing area. Inherited from CustomDrawEventArgs. |
Cache | Gets an object which specifies the storage for the most used pens, fonts and brushes. Inherited from CustomDrawEventArgs. |
CategoryIndents | Gets a collection of category indents to be painted. |
Graphics | Gets an object used to paint. Inherited from CustomDrawEventArgs. |
Handled | Gets or sets a value specifying whether an event was handled, if handled, default actions are not required. Inherited from CustomDrawEventArgs. |
IsRightToLeft | Gets a value indicating whether the VGridControl‘s elements are aligned to support locales using right-to-left fonts. Inherited from CustomDrawEventArgs. |
ObjectArgs | Gets an object containing information about the painted element. Inherited from CustomDrawEventArgs. |
Painter | Gets the painter object that provides the default element’s painting mechanism. Inherited from CustomDrawEventArgs. |
Properties | Provides properties specific to the row being custom painted. Inherited from CustomDrawRowEventArgs. |
Row | Gets the row whose element is to be drawn. Inherited from CustomDrawRowEventArgs. |
RowIndents | Gets a collection of row indents that are going to be painted. |
The event data class exposes the following methods:
Method | Description |
---|---|
DefaultDraw() | Performs default painting of an element. Inherited from CustomDrawEventArgs. |
DrawHtml(HtmlTemplate, DxHtmlPainterContext, Action<DxHtmlPainterArgs>) | Paints the required HTML template inside an element that raised this event. The context parameter allows you to assign an object that transfers mouse events to template elements. Inherited from CustomDrawEventArgs. |
DrawHtml(HtmlTemplate, Action<DxHtmlPainterArgs>) | Paints the required HTML template inside an element that raised this event. Inherited from CustomDrawEventArgs. |
Remarks
The CustomDrawRowHeaderIndent event is raised before a row header indent is painted. The row where the processed indent resides can be obtained via the event parameter’s CustomDrawRowEventArgs.Row property. The CustomDrawRowHeaderIndentEventArgs.CategoryIndents and CustomDrawRowHeaderIndentEventArgs.RowIndents parameters provide access to the collections of category and row indents. Individual indents can be accessed using index notation.
The CustomDrawRowHeaderIndent event can be used for two purposes:
- To manually paint all or only particular row header indents. Note that you need to set the CustomDrawEventArgs.Handled parameter to true to indicate that the default painting is not required for the indent.
- Change the indent’s appearance settings and leave the CustomDrawEventArgs.Handled parameter set to false. This will paint the row header indent using the default mechanism but with modified settings.
Important
Do not change cell values, modify the control’s layout, or change the control’s object model in the events used for custom control painting. Actions that update the layout can cause the control to malfunction.
Example
The following sample code handles the VGridControlBase.CustomDrawRowHeaderCell and VGridControlBase.CustomDrawRowHeaderIndent
events to custom paint the focused row header and its indents. If the focused row is a category row, it is painted in the default manner.
The image below shows the result.
using System.Drawing.Drawing2D;
using DevExpress.XtraVerticalGrid.ViewInfo;
using DevExpress.XtraVerticalGrid.Events;
private void vGridControl1_CustomDrawRowHeaderCell(object sender,
CustomDrawRowHeaderCellEventArgs e) {
if(e.Row.XtraRowTypeID != 0 && e.Focused) {
// Creates the brush which is used to fill the background of row headers.
using(var backBrush = new LinearGradientBrush(e.Bounds, Color.Orange,
e.Appearance.BackColor2, LinearGradientMode.Vertical))
e.Cache.FillRectangle(backBrush, e.Bounds);
// Paints the row header's caption.
e.Cache.DrawString(e.Caption, e.Appearance.Font, Brushes.DarkBlue,
e.CaptionRect, e.Appearance.GetStringFormat());
// Paints the row header's image.
e.Cache.DrawImage(imageList1.Images[0], e.ImageRect);
e.Handled = true;
}
}
private void vGridControl1_CustomDrawRowHeaderIndent(object sender,
CustomDrawRowHeaderIndentEventArgs e) {
VGridControl grid = sender as VGridControl;
if(e.Row.XtraRowTypeID == 0)
return;
if(e.Row == grid.FocusedRow) {
// Fills the category indent's background.
foreach(IndentInfo indInfo in e.CategoryIndents)
using(var categoryIndentBrush = new LinearGradientBrush(indInfo.Bounds,
indInfo.Style.BackColor, indInfo.Style.BackColor,
LinearGradientMode.Vertical))
e.Cache.FillRectangle(categoryIndentBrush, indInfo.Bounds);
// Fills the row indent's background.
if(e.RowIndents.Count - 1 > -1) {
for(int i = 0; i < e.RowIndents.Count - 1; i++)
using(var rowIndentBrush = new LinearGradientBrush(e.RowIndents[i].Bounds,
e.RowIndents[i].Style.BackColor, e.RowIndents[i].Style.BackColor2,
LinearGradientMode.Vertical))
e.Cache.FillRectangle(rowIndentBrush, e.RowIndents[i].Bounds);
// Creates the brush which is used to fill the background of row indents.
using(var backBrush = new LinearGradientBrush(e.Bounds, Color.Orange,
e.Appearance.BackColor2, LinearGradientMode.Vertical))
e.Cache.FillRectangle(backBrush, e.RowIndents[e.RowIndents.Count - 1].Bounds);
}
e.Handled = true;
}
}