Skip to main content
All docs
V23.2

SchedulerControl.CustomDayViewColumnWidth Event

Allows you to set custom relative widths to DayView, WorkWeekView and FullWeekView columns.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v23.2.dll

NuGet Package: DevExpress.Win.Scheduler

Declaration

public event CustomDayViewColumnWidthEventHandler CustomDayViewColumnWidth

Event Data

The CustomDayViewColumnWidth event's data class is DevExpress.XtraScheduler.CustomDayViewColumnWidthEventArgs.

Remarks

Event arguments provide access to a list of DayViewColumnLayoutInfo objects. Each object is associated with one of the visible columns, and allows you to retrieve or set up the following information:

  • DayViewColumnLayoutInfo.Interval - allows you to identify a column’s date.
  • DayViewColumnLayoutInfo.Resource - returns a Scheduler Resource that owns this column.
  • DayViewColumnLayoutInfo.ResourceCategory - returns a resource category that owns the column’s parent resource.
  • DayViewColumnLayoutInfo.RelativeWidth - set this integer value to specify the column width in relative units. If the DayView.ColumnWidthMode property equals Auto, this property returns the automatically calculated column width. In Fixed mode, all columns are of the same width and RelativeWidth always returns “1”.

Example 1

The following sample illustrates how to make week day columns three times as wide as weekend columns.

Custom column widhts in Scheduler

void OnCustomDayViewColumnWidth(object sender, CustomDayViewColumnWidthEventArgs e) {
    foreach (var info in e.DayViewColumnLayoutInfos) {
        if (info.Interval.Start.DayOfWeek == DayOfWeek.Saturday || 
            info.Interval.Start.DayOfWeek == DayOfWeek.Sunday)
            info.RelativeWidth = 1;
        else
            info.RelativeWidth = 3;
    }
}

Example 2

If the DayView.ColumnWidthMode property equals Auto, columns resize proportionally to their content. The more appointments are scheduled for the same time slot, the wider their parent column is. The code below illustrates how to limit the maximum column width by 3 relative units.

void OnCustomDayViewColumnWidth(object sender, CustomDayViewColumnWidthEventArgs e) {
    foreach (var info in e.DayViewColumnLayoutInfos)
        if (info.RelativeWidth > 3) info.RelativeWidth = 3;
}
See Also