Skip to main content

TabbedView.CustomDrawTabHeader Event

Allows you to draw a tab header manually.

Namespace: DevExpress.XtraBars.Docking2010.Views.Tabbed

Assembly: DevExpress.XtraBars.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public event TabHeaderCustomDrawEventHandler CustomDrawTabHeader

Event Data

The CustomDrawTabHeader event's data class is TabHeaderCustomDrawEventArgs. The following properties provide information specific to this event:

Property Description
Bounds Gets the rectangle that specifies the bounds of the tab header.
Cache Provides access to the drawing surface and a cache of pens, fonts, and brushes.
ControlInfo Gets an object that contains information about the tab being drawn.
Graphics Provides access to the drawing surface.
Handled Gets or sets whether the event is handled and prevents the default draw operation from being performed.
Painter Provides access to the object that performs paint operations.
TabHeaderInfo Provides access to the object that contains information about the page being drawn.
TabHeaderRowInfo Provides access to the object that contains information about the row being drawn.

The event data class exposes the following methods:

Method Description
DefaultDraw() Draws the visual element according to the default algorithm.
DefaultDrawBackground() Draws the visual element’s background according to the default algorithm.
DefaultDrawButtons() Draws the visual element’s buttons according to the default algorithm.
DefaultDrawImage() Draws the visual element’s icon according to the default algorithm.
DefaultDrawText() Draws the visual element’s text according to the default algorithm.
DrawHtml(HtmlTemplate, DxHtmlPainterContext, Action<DxHtmlPainterArgs>) Paints the required HTML template inside an element that raised this event. The context parameter allows you to assign an object that transfers mouse events to template elements.
DrawHtml(HtmlTemplate, Action<DxHtmlPainterArgs>) Paints the required HTML template inside an element that raised this event.

Example

The code below shows how to draw a custom background in tab headers and header buttons.

image

using System.Drawing.Drawing2D;

HatchBrush myHatchBrush1 = new HatchBrush(HatchStyle.BackwardDiagonal, Color.LightGray, Color.AliceBlue);
private void TabbedView_CustomDrawTabHeader(object sender, XtraTab.TabHeaderCustomDrawEventArgs e) {
    e.Cache.FillRectangle(myHatchBrush1, e.Bounds);
    e.DefaultDrawText();
    e.DefaultDrawImage();
    e.DefaultDrawButtons();
    e.Handled = true;
}
HatchBrush myHatchBrush2 = new HatchBrush(HatchStyle.DiagonalCross, Color.LightGray, Color.AliceBlue);
private void TabbedView_CustomDrawHeaderButton(object sender, XtraTab.HeaderButtonCustomDrawEventArgs e) {
    e.Cache.FillRectangle(myHatchBrush2, e.Bounds);
    e.DefaultDraw();
    e.Handled = true;
}

The following example demonstrates how to obtain the bounds of a tab header and its UI elements, and the document itself:

using System.Drawing.Drawing2D;

private void TabbedView1_CustomDrawTabHeader(object sender, DevExpress.XtraTab.TabHeaderCustomDrawEventArgs e) {
    // Gets the document.
    var document = (e.TabHeaderInfo.Page as IDocumentInfo).Document;
    var tabHeaderBounds = e.Bounds;
    var textBounds = e.TabHeaderInfo.Text;
    var buttonBounds = e.TabHeaderInfo.ButtonsPanel.Bounds;
    /*
     * Draw the tab header and its UI elements.
     * ...
     */
}
See Also