A newer version of this page is available. Switch to the current version.

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.
    e.Cache.FillRectangle(new LinearGradientBrush(e.Bounds,
        Color.LightBlue, Color.Blue, LinearGradientMode.Vertical), e.Bounds);
    Rectangle innerRect = Rectangle.Inflate(e.Bounds, -2, -2);
    // Draws the inner rectangle.
    e.Cache.FillRectangle(new LinearGradientBrush(e.Bounds,
        Color.Blue, Color.LightSkyBlue, LinearGradientMode.Vertical), innerRect);
    // Draws the header's caption.
    e.Cache.DrawString(header.Caption, header.Appearance.HeaderCaption.Font,
        new SolidBrush(Color.White), innerRect,
        header.Appearance.HeaderCaption.GetStringFormat());
    e.Handled = true;
}
See Also