windowsforms-devexpress-dot-xtrascheduler-dot-schedulercontrol-830cff11.md
Use this event to customize the appearance of certain visual elements before they are painted.
Namespace : DevExpress.XtraScheduler
Assembly : DevExpress.XtraScheduler.v25.2.dll
NuGet Package : DevExpress.Win.Scheduler
public event EventHandler<LayoutViewInfoCustomizingEventArgs> LayoutViewInfoCustomizing
Public Event LayoutViewInfoCustomizing As EventHandler(Of LayoutViewInfoCustomizingEventArgs)
The LayoutViewInfoCustomizing event's data class is LayoutViewInfoCustomizingEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Cache | |
| Kind | Gets the type of a visual element that raises the event. |
| ShouldRecalculateLayout | Forces layout recalculation after applying changes specified in the event handler. |
| ViewInfo | Provides access to the object which contains the information used to render the layout element. |
The LayoutViewInfoCustomizing event allows you to implement conditional styling of visual elements contained in the Scheduler view based on the resource and time interval.
The LayoutViewInfoCustomizing event occurs before painting a visual element of the Scheduler view, such as the time cell, day header, day-of-week header or resource header.
Use the LayoutViewInfoCustomizingEventArgs.Kind property to distinguish between a cell and a header. Subsequently, you can cast the LayoutViewInfoCustomizingEventArgs.ViewInfo object to a proper type and modify it as your needs dictate.
This example handles the SchedulerControl.LayoutViewInfoCustomizing event to change the color of time cells and header captions. The header’s caption indicates the type of ViewInfo object that is used to visualize the header.
public static void scheduler_LayoutViewInfoCustomizing(object sender, LayoutViewInfoCustomizingEventArgs e) {
string s = e.ViewInfo.GetType().ToString().Substring("DevExpress.XtraScheduler.Drawing.".Length);
if (e.Kind == LayoutElementKind.DateHeader) {
SchedulerHeader header = e.ViewInfo as SchedulerHeader;
if (header != null) header.Caption = s;
}
if (e.Kind == LayoutElementKind.Cell) {
SchedulerViewCellBase cell = e.ViewInfo as SchedulerViewCellBase;
if (cell != null) cell.Appearance.BackColor = Color.LightYellow;
SingleWeekCellBase cellWeek = e.ViewInfo as SingleWeekCellBase;
if (cellWeek != null) {
cellWeek.Appearance.BackColor = Color.LightCyan;
cellWeek.Header.Caption = s;
}
}
}
Public Shared Sub scheduler_LayoutViewInfoCustomizing(ByVal sender As Object, ByVal e As LayoutViewInfoCustomizingEventArgs)
Dim s As String = e.ViewInfo.GetType().ToString().Substring("DevExpress.XtraScheduler.Drawing.".Length)
If e.Kind = LayoutElementKind.DateHeader Then
Dim header As SchedulerHeader = TryCast(e.ViewInfo, SchedulerHeader)
If header IsNot Nothing Then
header.Caption = s
End If
End If
If e.Kind = LayoutElementKind.Cell Then
Dim cell As SchedulerViewCellBase = TryCast(e.ViewInfo, SchedulerViewCellBase)
If cell IsNot Nothing Then
cell.Appearance.BackColor = Color.LightYellow
End If
Dim cellWeek As SingleWeekCellBase = TryCast(e.ViewInfo, SingleWeekCellBase)
If cellWeek IsNot Nothing Then
cellWeek.Appearance.BackColor = Color.LightCyan
cellWeek.Header.Caption = s
End If
End If
End Sub
See Also