Back to Devexpress

XtraTabbedMdiManager.CustomDrawTabHeader Event

windowsforms-devexpress-dot-xtratabbedmdi-dot-xtratabbedmdimanager-c34e8830.md

latest6.3 KB
Original Source

XtraTabbedMdiManager.CustomDrawTabHeader Event

Allows you to draw a tab header manually.

Namespace : DevExpress.XtraTabbedMdi

Assembly : DevExpress.XtraBars.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Appearance")]
public event TabHeaderCustomDrawEventHandler CustomDrawTabHeader
vb
<DXCategory("Appearance")>
Public Event CustomDrawTabHeader As TabHeaderCustomDrawEventHandler

Event Data

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

PropertyDescription
BoundsGets the rectangle that specifies the bounds of the tab header.
CacheProvides access to the drawing surface and a cache of pens, fonts, and brushes.
ControlInfoGets an object that contains information about the tab being drawn.
GraphicsProvides access to the drawing surface.
HandledGets or sets whether the event is handled and prevents the default draw operation from being performed.
PainterProvides access to the object that performs paint operations.
TabHeaderInfoProvides access to the object that contains information about the page being drawn.
TabHeaderRowInfoProvides access to the object that contains information about the row being drawn.

The event data class exposes the following methods:

MethodDescription
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.

csharp
using System.Drawing.Drawing2D;

HatchBrush myHatchBrush2 = new HatchBrush(HatchStyle.DiagonalCross, Color.LightGray, Color.AliceBlue);
private void XtraTabbedMdiManager1_CustomDrawHeaderButton(object sender, XtraTab.HeaderButtonCustomDrawEventArgs e) {
    e.Cache.FillRectangle(myHatchBrush2, e.Bounds);
    e.DefaultDraw();
    e.Handled = true;
}

HatchBrush myHatchBrush1 = new HatchBrush(HatchStyle.BackwardDiagonal, Color.LightGray, Color.AliceBlue);
private void XtraTabbedMdiManager1_CustomDrawTabHeader(object sender, XtraTab.TabHeaderCustomDrawEventArgs e) {
    e.Cache.FillRectangle(myHatchBrush1, e.Bounds);
    e.DefaultDrawText();
    e.DefaultDrawImage();
    e.DefaultDrawButtons();
    e.Handled = true;
}
vb
Imports System.Drawing.Drawing2D

Private myHatchBrush2 As New HatchBrush(HatchStyle.DiagonalCross, Color.LightGray, Color.AliceBlue)
Private Sub XtraTabbedMdiManager1_CustomDrawHeaderButton(ByVal sender As Object, ByVal e As XtraTab.HeaderButtonCustomDrawEventArgs) _
    Handles xtraTabbedMdiManager1.CustomDrawHeaderButton
    e.Cache.FillRectangle(myHatchBrush2, e.Bounds)
    e.DefaultDraw()
    e.Handled = True
End Sub

Private myHatchBrush1 As New HatchBrush(HatchStyle.BackwardDiagonal, Color.LightGray, Color.AliceBlue)
Private Sub XtraTabbedMdiManager1_CustomDrawTabHeader(ByVal sender As Object, ByVal e As XtraTab.TabHeaderCustomDrawEventArgs) _
    Handles xtraTabbedMdiManager1.CustomDrawTabHeader
    e.Cache.FillRectangle(myHatchBrush1, e.Bounds)
    e.DefaultDrawText()
    e.DefaultDrawImage()
    e.DefaultDrawButtons()
    e.Handled = True
End Sub

See Also

CustomDrawHeaderButton

XtraTabbedMdiManager Class

XtraTabbedMdiManager Members

DevExpress.XtraTabbedMdi Namespace