Skip to main content

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