Back to Devexpress

How to: Fill Resource Headers with Specific Colors

aspnet-11231-components-scheduler-examples-customization-appearance-how-to-fill-resource-headers-with-specific-colors.md

latest1.9 KB
Original Source

How to: Fill Resource Headers with Specific Colors

  • Dec 17, 2020

This example demonstrates how to fill all resource headers with specific colors obtained from the ASPxScheduler.ResourceColorSchemas collection by handling the ASPxScheduler.CustomizeElementStyle event.

csharp
using DevExpress.Web.ASPxScheduler;
// ...

protected void ASPxScheduler1_CustomizeElementStyle(object sender, CustomizeElementStyleEventArgs e) {
    if (e.ElementType == WebElementType.VerticalResourceHeader) {
        int id = ASPxScheduler1.Storage.Resources.Items.IndexOf(e.Cell.Resource);
        e.Style.BackColor = ASPxScheduler1.ResourceColorSchemas[id % ASPxScheduler1.ResourceColorSchemas.Count].Cell;
    }
}
vb
Imports DevExpress.Web.ASPxScheduler
' ...

Protected Sub ASPxScheduler1_CustomizeElementStyle(ByVal sender As Object, _
                                                   ByVal e As CustomizeElementStyleEventArgs)
    If e.ElementType = WebElementType.VerticalResourceHeader Then
        Dim id As Integer = ASPxScheduler1.Storage.Resources.Items.IndexOf(e.Cell.Resource)
        e.Style.BackColor = ASPxScheduler1.ResourceColorSchemas(id Mod ASPxScheduler1.ResourceColorSchemas.Count).Cell
    End If
End Sub

As a result, resource headers will be colored as time/date cells associated with corresponding resources.

See Also

How to: Customize Resource Headers