VGridControl.CustomDrawRecordHeader Event
Allows you to paint record headers.
Namespace: DevExpress.XtraVerticalGrid
Assembly: DevExpress.XtraVerticalGrid.v24.1.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:
- Set the record header format (the VGridControl.RecordHeaderFormat property).
- Handle the VGridControl.CustomRecordHeaderDisplayText event to dynamically supply record header text.
- Handle the CustomDrawRecordHeader event to paint record headers.
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.
See the following demo for the complete code:
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);
}
//...
}