Scheduler for WinForms | ComponentOne
In This Topic
    Scheduler for WinForms Top Tips
    In This Topic

    The following tips were compiled from frequently asked user questions posted in the Scheduler for WinForms online forum.

    Tip 1: Disable Updating C1Schedule while Filling the Underlying Data Source

    When you bind the C1Schedule control to a data source, every change in the underlying data source forces the C1Schedule control to update. This could affect performance, especially when loading a large amount of data. To disable updating, you can call the BeginUpdate method before data operations and call the EndUpdate when the operations are complete. For example:

    C#
    Copy Code
    // Disable updating    
    this.c1Schedule1.BeginUpdate();   
    // Fill datasets with data   
    this.productsTableAdapter.Fill(this.nwindDataSet1.Products);   
    this.employeesTableAdapter.Fill(nwindDataSet.Employees);   
    this.appointmentsTableAdapter.Fill(nwindDataSet.Appointments);   
    // Enable updating   
    this.c1Schedule1.EndUpdate();
    

    Tip 2: Use the CustomData and Tag Properties to Keep Additional Information

    If needed, you can store additional appointment information in the C1Schedule control. The Appointment class has two properties which can be used to keep custom information:

    Tip 3: Extracting All Appointments for Particular Period of Time

    To get all Appointment objects for particular time period, use appropriate overload of GetOccurrences method. This method returns all events in the specified period, including recurring events occurrences. For example:

    C#
    Copy Code
    AppointmentList todayAppointments = c1Schedule1.DataStorage.AppointmentStorage.Appointments.GetOccurrences(DateTime.Today, DateTime.Today.AddDays(1));
    

    Tip 4: Customize Appointment Appearance

    You can change appointment appearance in the BeforeAppointmentFormat event's event handler. The Text property accepts HTML to customize the display in the control. Or example, you can use the following code to insert a custom image:

    C#
    Copy Code
    e.Text = "<div><img src=res://myIcon.gif/></div>";
    

    In the above code the myIcon.gif image will be extracted from your application resources and inserted into appointment. You can change other BeforeAppointmentFormatEventArgs properties as well. Note that this information won't be saved to underlying datasource, you should handle appointment information and apply formatting from your code at run time. For example:

    C#
    Copy Code
    private void c1Schedule1_BeforeAppointmentFormat(object sender, BeforeAppointmentFormatEventArgs e)   
    {   
        if (e.Appointment.ReminderSet)   
        {   
        e.Icons |= AppointmentIcons.Reminder;   
        }   
        if (!String.IsNullOrEmpty(e.Text) &&   
            e.Appointment.Importance == ImportanceEnum.High)   
        {   
            e.Text = "<div style=\"color:red\"><b>" + e.Text + "</b></div>";   
        }   
        if (String.IsNullOrEmpty(e.Text) &&   
            !String.IsNullOrEmpty(e.Appointment.Body))   
        {   
            e.Text = "<a href=more>More info...</a>";   
        }   
        else   
        {   
            e.Text = "<div><img src=res://myIcon.gif/></div>";   
        }   
    }
    

    Tip 5: Customize Appointment ToolTips

    Appointment ToolTips can include HTML markup, allowing you to customize ToolTips easily. You can change a ToolTip in the BeforeAppointmentTooltipShow event's event handler. For example:

    C#
    Copy Code
    private void c1Schedule1_BeforeAppointmentTooltipShow(object sender, BeforeAppointmentTooltipShowEventArgs e)   
    {   
        e.Text = "<img src='res://c1icon_bottom3.gif'>" + "<br/>" +   
        e.Appointment.Start.ToShortTimeString() +   
        " <b>" + e.Appointment.Subject + "</b><br/>" + e.Appointment.Body;   
    }