VGridControlBase.CustomDrawSeparator Event
Enables cell separators to be painted manually.
Namespace: DevExpress.XtraVerticalGrid
Assembly: DevExpress.XtraVerticalGrid.v19.1.dll
Declaration
Event Data
The CustomDrawSeparator event's data class is CustomDrawSeparatorEventArgs. 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. |
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. |
IsHeaderSeparator | Gets a value indicating whether the painted cell separator is contained within the row header. |
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 painted cell separator’s owning row. |
SeparatorIndex | Gets the painted cell separator’s index. |
SeparatorKind | Gets the painted cell separator’s type. |
SeparatorString | Gets or sets the painted cell separator’s text. |
The event data class exposes the following methods:
Method | Description |
---|---|
DefaultDraw() | Performs default painting of an element. Inherited from CustomDrawEventArgs. |
Remarks
The CustomDrawSeparator event is raised before a cell separator is painted. The cell separator is identified by the CustomDrawSeparatorEventArgs.Row and CustomDrawSeparatorEventArgs.SeparatorIndex properties. Its type can be obtained using the CustomDrawSeparatorEventArgs.SeparatorKind property. The event parameter’s CustomDrawSeparatorEventArgs.IsHeaderSeparator property allows you to identify whether the processed separator is contained within the row header.
The CustomDrawSeparator event can be used for two purposes:
- To manually paint all or only particular cell separators. Note that you need to set the CustomDrawEventArgs.Handled parameter to true to indicate that the default painting is not required for the separator.
- Change the separator’s settings (text if displayed, appearance) and leave the CustomDrawEventArgs.Handled parameter set to false. This will paint separators using the default mechanism but with modified settings.
Important
Never change cell values or modify the control’s layout on this event, or any other event designed to tune the control’s appearance. Any action that causes a layout update can cause the control to malfunction.
Example
The following sample code handles the VGridControlBase.CustomDrawSeparator
event to custom paint cell separators. The image below shows the result.
using System.Drawing.Drawing2D;
using DevExpress.XtraVerticalGrid.Events;
// ...
private void vGridControl1_CustomDrawSeparator(object sender, CustomDrawSeparatorEventArgs e) {
switch (e.SeparatorIndex) {
case 0:
// Fills the background.
e.Graphics.FillRectangle(new LinearGradientBrush(e.Bounds, Color.Yellow, Color.Orange,
LinearGradientMode.Vertical), e.Bounds);
ControlPaint.DrawBorder3D(e.Graphics, e.Bounds);
e.SeparatorString = ",";
// Paints the text which is displayed within the separator.
e.Graphics.DrawString(e.SeparatorString, e.Appearance.Font,
new SolidBrush(Color.DarkBlue), e.Bounds, e.Appearance.GetStringFormat());
break;
case 1:
e.Graphics.FillRectangle(new LinearGradientBrush(e.Bounds, Color.Orange, Color.Yellow,
LinearGradientMode.Vertical), e.Bounds);
ControlPaint.DrawBorder3D(e.Graphics, e.Bounds);
e.SeparatorString = "/";
e.Graphics.DrawString(e.SeparatorString, e.Appearance.Font,
new SolidBrush(Color.DarkBlue), e.Bounds, e.Appearance.GetStringFormat());
break;
default:
break;
}
e.Handled = true;
}