How to: Display Custom Day Headers

  • 2 minutes to read

This document illustrates the use of HeaderCaptionService to change the display format of a Day View column header.

To accomplish this, substitute the service with a custom service which contains method overrides. The list of methods which can be overridden is found in the Formatting Services topic.

The following code implements a descendant class which displays a New Year's greeting in the day header:


public class CustomHeaderCaptionService : HeaderCaptionServiceWrapper {
    public CustomHeaderCaptionService(IHeaderCaptionService service) : base(service) {
    }
    #region IHeaderCaptionService Members
    public override string GetDayColumnHeaderCaption(DayHeader header) {
        DateTime date = header.Interval.Start.Date;
        if (date.Month == 1 && date.Day == 1)
            return "{0:yyyy} Happy New Year!";
        else
            return base.GetDayColumnHeaderCaption(header);
    }
    #endregion
}

You should create a service and substitute a default service with a custom one. The technique is identical to that demonstrated in the How to: Display TimeRulers with Different Time Formats Together article.

TIP

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E507.

See Also