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

VGridControl.CustomDrawRecordHeader Event

Allows you to paint record headers.

Namespace: DevExpress.XtraVerticalGrid

Assembly: DevExpress.XtraVerticalGrid.v24.2.dll

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

#Declaration

[DXCategory("Appearance")]
public event CustomDrawRecordHeaderEventHandler CustomDrawRecordHeader

#Event Data

The CustomDrawRecordHeader event's data class is DevExpress.XtraVerticalGrid.Events.CustomDrawRecordHeaderEventArgs.

#Remarks

Enable the VGridOptionsView.ShowRecordHeaders property to display record headers.

You can specify record header content as follows:

#Example

The following VGridControl.CustomDrawRecordHeader event handler paints the record header element using default settings, and then draws a rounded rectangle with text within the header.

VGrid - CustomDrawRecordHeader

See the following demo for the complete code:

Run Demo: PC Market

void OnCustomDrawRecordHeader(object sender, Events.CustomDrawRecordHeaderEventArgs e) {
    //skip code...
    // Draw the record header element using default settings.
    e.DefaultDraw();
    // Set the 'Handled' parameter to true to indicate that no default processing is required 
    // after the event handler is complete.
    e.Handled = true;
    //...
    int dataSourceRowIndex = vGrid.GetDataSourceRecordIndex(e.Record);
    bool addedToCart = Orders.Contains(dataSourceRowIndex);
    var color = addedToCart ? DXSkinColors.FillColors.Success : DXSkinColors.FillColors.Question;
    e.Cache.FillRoundedRectangle(color, linkRect, new CornerRadius(9));
    using (var format = new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
    using (var font = new Font(linkBlock.Font.FontFamily, linkBlock.Font.Size, FontStyle.Bold)) {
        var text = addedToCart ? linkBlock.Text : defaultCartLinkText;
        e.Cache.DrawString(text, font, Brushes.White, linkRect, format);
    }
    //...
}
See Also