How to: Merge Columns to Hide Specific Time Intervals in the Timeline View
- 4 minutes to read
This example illustrates how to hide columns for certain (non-working) hours in the Timeline View.
To accomplish this task, you can implement a custom time scale. It enables you to hide unneeded time periods.
A custom time scale class is inherited from the TimeScale class, overriding methods used for date and time handling and formatting.
The following properties and methods can be overridden to create a custom time scale:
- SortingWeight - used to compare time scales;
- TimeScale.Floor - specifies column boundaries;
- HasNextDate - checks whether moving to the next date is allowed;
- GetNextDate - navigates to the next date;
- DefaultDisplayFormat - specifies the format for the column header caption;
- DefaultMenuCaption - specifies the caption for the context menu item which enables this time scale;
- TimeScale.FormatCaption - returns a string to be displayed as a column header caption.
To ensure proper alignment of an upper (Day) scale, create a descendant of the TimeScaleDay class that overrides the TimeScaleDay.Floor method. Add this descendant to the TimelineView.Scales collection in place of the default TimeScaleDay scale.
The resulting Timeline View is demonstrated in the following picture.
Actually, non-working hours are not hidden. They are packed within the last time cell of each day because the time line has to be continuous.