Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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.v24.2.dll

NuGet Package: DevExpress.Win.Navigation

#Declaration

[DXCategory("Events")]
public event CustomDrawElementEventHandler CustomDrawElement

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

customdraw

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)));
    }
}
See Also