Scheduler for WinForms | ComponentOne
C1.Win.C1Schedule.4.5.2 Assembly / C1.Win.C1Schedule Namespace / C1Schedule Class / BeforeTimeFormat Event
Example

In This Topic
    BeforeTimeFormat Event (C1Schedule)
    In This Topic
    Occurs before the time interval is formatted.
    Syntax
    'Declaration
     
    Public Event BeforeTimeFormat As System.EventHandler(Of BeforeTimeFormatEventArgs)
    public event System.EventHandler<BeforeTimeFormatEventArgs> BeforeTimeFormat
    Event Data

    The event handler receives an argument of type BeforeTimeFormatEventArgs containing data related to this event. The following BeforeTimeFormatEventArgs properties provide information specific to this event.

    PropertyDescription
    Gets or sets System.Drawing.Color value specifying custom background color for the time interval element.  
    Gets the System.TimeSpan value determining the duration of the time interval to format.  
    Gets the ScheduleGroupItem object which is currently formatted.  
    Gets the System.DateTime value determining the start date and time of the time interval to format.  
    Gets or sets a value indicating whether time interval should be displayed as a working time.  
    Remarks
    Use this event to alter default time interval appearance. For example, to display different working hours for different days.
    Example
    This sample shows how to alter time interval appearance depending on BeforeTimeFormatEventArgs properties.
    private void c1Schedule1_BeforeTimeFormat(object sender, BeforeTimeFormatEventArgs e)
    {
        if (e.Start.TimeOfDay == TimeSpan.FromMinutes(120))
        {
            e.WorkTime = true;
            if (e.Start.DayOfWeek == DayOfWeek.Sunday)
            {
                e.Background = Color.Red;
            }
        }
        else if (e.Start.TimeOfDay == TimeSpan.FromMinutes(240) &&  e.Start.DayOfWeek != DayOfWeek.Sunday)
        {
            e.Background = c1Schedule1.Theme.Palette.FreeHourBorder;
       }
        else
        {
            if (e.Start.DayOfWeek == DayOfWeek.Sunday && e.Duration.TotalDays == 1)
            {
                e.Background = Color.Navy;
            }
        }
    }
    See Also