Back to Devexpress

SchedulerControl.CustomDayViewColumnWidth Event

windowsforms-devexpress-dot-xtrascheduler-dot-schedulercontrol-2c2e099f.md

latest4.2 KB
Original Source

SchedulerControl.CustomDayViewColumnWidth Event

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

Namespace : DevExpress.XtraScheduler

Assembly : DevExpress.XtraScheduler.v25.2.dll

NuGet Package : DevExpress.Win.Scheduler

Declaration

csharp
public event CustomDayViewColumnWidthEventHandler CustomDayViewColumnWidth
vb
Public Event CustomDayViewColumnWidth As CustomDayViewColumnWidthEventHandler

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.

csharp
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;
    }
}
vb
Private Sub OnCustomDayViewColumnWidth(ByVal sender As Object, ByVal e As CustomDayViewColumnWidthEventArgs)
    For Each info In e.DayViewColumnLayoutInfos
        If info.Interval.Start.DayOfWeek = DayOfWeek.Saturday OrElse info.Interval.Start.DayOfWeek = DayOfWeek.Sunday Then
            info.RelativeWidth = 1
        Else
            info.RelativeWidth = 3
        End If
    Next info
End Sub

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.

csharp
void OnCustomDayViewColumnWidth(object sender, CustomDayViewColumnWidthEventArgs e) {
    foreach (var info in e.DayViewColumnLayoutInfos)
        if (info.RelativeWidth > 3) info.RelativeWidth = 3;
}
vb
Private Sub OnCustomDayViewColumnWidth(ByVal sender As Object, ByVal e As CustomDayViewColumnWidthEventArgs)
    For Each info In e.DayViewColumnLayoutInfos
        If info.RelativeWidth > 3 Then
            info.RelativeWidth = 3
        End If
    Next info
End Sub

See Also

SchedulerControl Class

SchedulerControl Members

DevExpress.XtraScheduler Namespace