Back to Devexpress

TabbedView.CustomDrawHeaderButton Event

windowsforms-devexpress-dot-xtrabars-dot-docking2010-dot-views-dot-tabbed-dot-tabbedview-0c78f989.md

latest5.5 KB
Original Source

TabbedView.CustomDrawHeaderButton Event

Allows you to draw a header button manually.

Namespace : DevExpress.XtraBars.Docking2010.Views.Tabbed

Assembly : DevExpress.XtraBars.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public event HeaderButtonCustomDrawEventHandler CustomDrawHeaderButton
vb
Public Event CustomDrawHeaderButton As HeaderButtonCustomDrawEventHandler

Event Data

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

PropertyDescription
BoundsGets the rectangle that specifies the bounds of the header button.
ButtonGets the button that is being drawn.
InfoProvides access to the object that contains information about the button being drawn.
PainterProvides access to the object that performs paint operations. Inherited from ObjectCustomDrawEventArgs.

Example

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

csharp
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;
}
vb
Imports System.Drawing.Drawing2D

Private myHatchBrush2 As New HatchBrush(HatchStyle.DiagonalCross, Color.LightGray, Color.AliceBlue)
Private Sub TabbedView1_CustomDrawHeaderButton(ByVal sender As Object, ByVal e As DevExpress.XtraTab.HeaderButtonCustomDrawEventArgs) _
    Handles tabbedView1.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 TabbedView1_CustomDrawTabHeader(ByVal sender As Object, ByVal e As DevExpress.XtraTab.TabHeaderCustomDrawEventArgs) _
    Handles tabbedView1.CustomDrawTabHeader
    e.Cache.FillRectangle(myHatchBrush1, e.Bounds)
    e.DefaultDrawText()
    e.DefaultDrawImage()
    e.DefaultDrawButtons()
    e.Handled = True
End Sub

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

csharp
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.
     * ...
     */
}
vb
Imports System.Drawing.Drawing2D

Private Sub TabbedView1_CustomDrawTabHeader(ByVal sender As Object, ByVal e As DevExpress.XtraTab.TabHeaderCustomDrawEventArgs)
    Dim document = (TryCast(e.TabHeaderInfo.Page, IDocumentInfo)).Document
    Dim tabHeaderBounds = e.Bounds
    Dim textBounds = e.TabHeaderInfo.Text
    Dim buttonBounds = e.TabHeaderInfo.ButtonsPanel.Bounds
    ' ...
End Sub

See Also

CustomHeaderButtons

CustomHeaderButtons

HeaderButtons

HeaderButtons

CustomDrawTabHeader

TabbedView Class

TabbedView Members

DevExpress.XtraBars.Docking2010.Views.Tabbed Namespace