SpreadsheetControl.CustomDrawRowHeaderBackground Event
Enables the row header background to be painted manually.
Namespace: DevExpress.XtraSpreadsheet
Assembly: DevExpress.XtraSpreadsheet.v24.2.dll
NuGet Package: DevExpress.Win.Spreadsheet
#Declaration
public event CustomDrawRowHeaderBackgroundEventHandler CustomDrawRowHeaderBackground
#Event Data
The CustomDrawRowHeaderBackground event's data class is CustomDrawRowHeaderBackgroundEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Appearance |
Provides access to the properties that control the appearance of a worksheet header.
Inherited from Custom |
Back |
Gets the background color of the header.
Inherited from Custom |
Bounds |
Gets the header’s bound rectangle.
Inherited from Custom |
Cache |
Gets an object that serves as the storage for pens, fonts and brushes.
Inherited from Custom |
Control |
Provides access to the Spreadsheet |
Font |
Gets the font used to paint the header caption.
Inherited from Custom |
Fore |
Gets the color used to paint the header caption text.
Inherited from Custom |
Graphics |
Gets an object used for painting.
Inherited from Custom |
Handled |
Gets or sets whether an event is handled. If true, the default actions are not required.
Inherited from Custom |
Is |
Gets whether a mouse is currently over the worksheet header.
Inherited from Custom |
Is |
Gets whether the current column contains selected cell |
Row |
Returns the row index of the column header being painted. |
Text |
Gets the text of the header caption.
Inherited from Custom |
The event data class exposes the following methods:
Method | Description |
---|---|
Draw |
Renders the element using the default drawing mechanism.
Inherited from Custom |
#Remarks
The CustomDrawRowHeaderBackground event is raised before a row header is painted. Event arguments properties provide the objects and information required to paint the row header background.
Set the CustomDrawObjectEventsArgs.Handled property to true to cancel default painting. Use the CustomDrawObjectEventsArgs.DrawDefault method to perform default painting within the event handler.
The following code snippet demonstrates how to change the background color for row headers. This example applies a dark red color to a row header under the mouse pointer or if a header belongs to a row with the active cell:
using System;
using System.Drawing;
using DevExpress.Spreadsheet;
using DevExpress.XtraSpreadsheet;
// ...
private void spreadsheetControl1_CustomDrawRowHeaderBackground(object sender,
CustomDrawRowHeaderBackgroundEventArgs e)
{
// Cancel default painting for the row header background.
e.Handled = true;
// If the row header is under the mouse pointer or the row contains the active cell,
// paint the row header background in Color 1.
// Otherwise, paint the row header in white.
Color backColor = e.IsHovered || (e.RowIndex == spreadsheetControl1.ActiveCell.RowIndex) ?
Color.FromArgb(200, 44, 74) : // Color 1
Color.White;
e.Cache.FillRectangle(e.Cache.GetSolidBrush(backColor), e.Bounds);
}
#Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomDrawRowHeaderBackground event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.