Back to Devexpress

AccordionControl.CustomDrawElement Event

windowsforms-devexpress-dot-xtrabars-dot-navigation-dot-accordioncontrol-4ce29a08.md

latest2.9 KB
Original Source

AccordionControl.CustomDrawElement Event

Fires before a group or item is displayed. Provides access to a drawing surface and allows you to draw the processed element.

Namespace : DevExpress.XtraBars.Navigation

Assembly : DevExpress.XtraBars.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Events")]
public event CustomDrawElementEventHandler CustomDrawElement
vb
<DXCategory("Events")>
Public Event CustomDrawElement As CustomDrawElementEventHandler

Event Data

The CustomDrawElement event's data class is DevExpress.XtraBars.Navigation.CustomDrawElementEventArgs.

Remarks

The following code from the Hamburger Menu demo calls the e.DrawHeaderBackground and e.DrawText methods to paint elements with default appearance, then uses the FillRectangle method to draw a white stripe along the left edge of a selected element.

csharp
private void accordionControl1_CustomDrawElement(object sender, CustomDrawElementEventArgs e) {
    if(e.ObjectInfo.Element == filterPeopleElement || e.ObjectInfo.Element == filterMailElement) {
        e.Handled = true;
        e.DrawHeaderBackground();
        e.DrawText();
        e.Cache.FillRectangle(
            e.ObjectInfo.PaintAppearance.ForeColor,
            new Rectangle(
                e.ObjectInfo.HeaderBounds.Location,
                new Size(ScaleHelper.ScaleHorizontal(3),
                e.ObjectInfo.HeaderBounds.Height)));
    }
}
vb
Private Sub accordionControl1_CustomDrawElement(ByVal sender As Object, ByVal e As CustomDrawElementEventArgs)
    If e.ObjectInfo.Element = filterPeopleElement
    OrElse e.ObjectInfo.Element = filterMailElement Then
        e.Handled = True
        e.DrawHeaderBackground()
        e.DrawText()
        e.Cache.FillRectangle(
          e.ObjectInfo.PaintAppearance.ForeColor,
          New Rectangle(
            e.ObjectInfo.HeaderBounds.Location,
            New Size(ScaleHelper.ScaleHorizontal(3),
            e.ObjectInfo.HeaderBounds.Height)))
    End If
End Sub

See Also

CustomDrawHamburgerButton

AccordionControl Class

AccordionControl Members

DevExpress.XtraBars.Navigation Namespace