Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

VGridControlBase.CustomDrawCaption Event

Allows you to paint the control’s caption.

Namespace: DevExpress.XtraVerticalGrid

Assembly: DevExpress.XtraVerticalGrid.v24.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