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

How to: Custom Paint Day Headers

  • 2 minutes to read

The following code handles the SchedulerControl.CustomDrawDayHeader event to manually paint day headers. The image below shows the result.

CustomDrawHeader

using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Drawing;
using System.Drawing.Drawing2D;
private void schedulerControl1_CustomDrawDayHeader(object sender, CustomDrawObjectEventArgs e) {
    DayHeader header = e.ObjectInfo as DayHeader;
    // Draws the outer rectangle.
    using(var backBrush = new LinearGradientBrush(e.Bounds,
            Color.LightBlue, Color.Blue, LinearGradientMode.Vertical))
        e.Cache.FillRectangle(backBrush, e.Bounds);
    Rectangle innerRect = Rectangle.Inflate(e.Bounds, -2, -2);
    // Draws the inner rectangle.
    using(var backBrush = new LinearGradientBrush(e.Bounds,
            Color.Blue, Color.LightSkyBlue, LinearGradientMode.Vertical))
        e.Cache.FillRectangle(backBrush, innerRect);
    // Draws the header's caption.
    e.Cache.DrawString(header.Caption, header.Appearance.HeaderCaption.Font,
        Brushes.White, innerRect,
        header.Appearance.HeaderCaption.GetStringFormat());
    e.Handled = true;
}
See Also