This example uses a custom scale (TimeScaleWorkWeekDay
) to hide weekends. The TimeScaleWorkWeekDay
class inherits base functionality from the TimeScaleDay
class and overrides the IsDateVisible
method:
public class TimeScaleWorkWeekDay : TimeScaleDay {
protected override string DefaultDisplayFormat { get { return "d ddd"; } }
protected override string DefaultMenuCaption { get { return "WorkWeek"; } }
public override bool IsDateVisible(DateTime date) {
return date.DayOfWeek != DayOfWeek.Sunday && date.DayOfWeek != DayOfWeek.Saturday;
}
}
The following code hides/shows weekends:
private void checkEdit1_CheckedChanged(object sender, EventArgs e) {
CheckEdit editor = sender as CheckEdit;
HideWeekends(editor.Checked);
}
private void HideWeekends(bool hide) {
TimeScaleCollection scales = schedulerControl1.TimelineView.Scales;
if (hide) {
scales.BeginUpdate();
try {
scales.Clear();
scales.Add(new TimeScaleMonth());
TimeScaleWorkWeekDay customWorkWeekScale = new TimeScaleWorkWeekDay();
customWorkWeekScale.Width = 125;
scales.Add(customWorkWeekScale);
}
finally {
scales.EndUpdate();
}
}
else {
scales.BeginUpdate();
try {
scales.Clear();
scales.Add(new TimeScaleMonth());
TimeScaleDay dayScale = new TimeScaleDay();
dayScale.Width = 125;
scales.Add(dayScale);
}
finally {
scales.EndUpdate();
}
}
}
- CustomTimeScale.cs (VB: CustomTimeScale.vb)
- Form1.cs (VB: Form1.vb)
(you will be redirected to DevExpress.com to submit your response)