Skip to main content
All docs
V23.2

VGridControlBase.CustomDrawCaption Event

Allows you to paint the control’s caption.

Namespace: DevExpress.XtraVerticalGrid

Assembly: DevExpress.XtraVerticalGrid.v23.2.dll

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

Declaration

[DXCategory("Appearance")]
public event CustomDrawCaptionEventHandler CustomDrawCaption

Event Data

The CustomDrawCaption event's data class is DevExpress.XtraVerticalGrid.Events.CustomDrawCaptionEventArgs.

Remarks

The following example handles the CustomDrawCaption event to paint the Vertical Grid’s caption.

CustomDrawCaption - WinForms Vertical Grid

using DevExpress.XtraVerticalGrid.Events;

private void vGridControl1_CustomDrawCaption(object sender, CustomDrawCaptionEventArgs e) {
    LinearGradientBrush outerBrush = new LinearGradientBrush(e.Bounds, Color.LightBlue, Color.Blue, LinearGradientMode.Vertical);
    using(outerBrush) {
        e.Cache.FillRectangle(outerBrush, e.Bounds);
    }

    Rectangle innerRect = Rectangle.Inflate(e.Bounds, -3, -3);
    LinearGradientBrush innerBrush = new LinearGradientBrush(innerRect, Color.Blue, Color.LightBlue, LinearGradientMode.Vertical);
    using(innerBrush) {
        e.Cache.FillRectangle(innerBrush, e.Bounds);
    }

    StringFormat outStrFormat = new StringFormat();
    outStrFormat.Alignment = StringAlignment.Center;
    outStrFormat.LineAlignment = StringAlignment.Center;
    e.Cache.DrawString(e.DisplayText, e.Appearance.Font, e.Cache.GetSolidBrush(Color.White), innerRect, outStrFormat);
    e.Handled = true;
}
See Also