Back to Devexpress

How to: Customize an Appointment Recurrence Form

windowsforms-2880-controls-and-libraries-scheduler-examples-forms-how-to-create-a-custom-appointment-recurrence-form-method-1.md

latest4.0 KB
Original Source

How to: Customize an Appointment Recurrence Form

  • Sep 24, 2023
  • 2 minutes to read

This document explains how to customize the dialog that allows users to modify recurrence settings.

Add and remove occurence pattern options

The default Appointment Recurrence form contains the “Daily”, “Weekly”, “Monthly” and “Yearly” pattern options.

The “Minutely” and “Hourly” patterns are hidden initially. Use the SchedulerOptionsCustomization.RecurrenceFormEditors property to choose which pattern options should be available to users.

csharp
schedulerControl1.OptionsCustomization.RecurrenceFormEditors =
    RecurrenceFormEditors.Minutely | RecurrenceFormEditors.Hourly | RecurrenceFormEditors.Daily;
vb
schedulerControl1.OptionsCustomization.RecurrenceFormEditors =
    RecurrenceFormEditors.Minutely Or RecurrenceFormEditors.Hourly Or RecurrenceFormEditors.Daily

Custom recurrence form (versions 19.1 and older)

In v19.1 and older, you can create an AppointmentRecurrenceForm descendant and handle the SchedulerControl.EditAppointmentFormShowing event to replace a default form with this custom form.

csharp
void schedulerControl1_EditAppointmentFormShowing(object sender, DevExpress.XtraScheduler.AppointmentFormEventArgs e)
{
    // The recurrence form allows you to edit only daily recurring appointments. 
    using(var myForm = new MyAppointmentEditForm(schedulerControl1,
            e.Appointment, e.OpenRecurrenceForm, DevExpress.XtraScheduler.RecurrenceType.Daily))
        myForm.ShowDialog();
    e.Handled = true;
}
vb
Private Sub schedulerControl1_EditAppointmentFormShowing(ByVal sender As Object, ByVal e As DevExpress.XtraScheduler.AppointmentFormEventArgs)
    ' The recurrence form allows you to edit only daily recurring appointments. 
    Using myForm = New MyAppointmentEditForm(schedulerControl1, e.Appointment, e.OpenRecurrenceForm, DevExpress.XtraScheduler.RecurrenceType.Daily)
        myForm.ShowDialog()
    End Using
    e.Handled = True
End Sub

See this GitHub example for a complete sample.

Custom recurrence form (versions 19.2 and newer)

In v19.1 and older, Appointment Recurrence Form editors were placed directly on the form’s surface. Starting with v19.2, the form uses the LayoutControl to arrange its editors. The Layout Control ensures that the form has a correct layout when shown on HiDPI devices.

Due to this change, you cannot create custom AppointmentRecurrenceForm descendants and use them in v19.2 and newer. If you upgrade to v19.2 and want to use your custom forms, change your custom forms’ base class from AppointmentRecurrenceForm to LegacyAppointmentRecurrenceForm.

csharp
//v19.1 and older
public class MyAppointmentRecurrenceForm : AppointmentRecurrenceForm {
    //...
}
//v19.2 and newer
public class MyAppointmentRecurrenceForm : LegacyAppointmentRecurrenceForm {
    //...
}
vb
'v19.1 and older
Public Class MyAppointmentRecurrenceForm
    Inherits AppointmentRecurrenceForm
    '...
End Class
'v19.2 and newer
Public Class MyAppointmentRecurrenceForm
    Inherits LegacyAppointmentRecurrenceForm
    '...
End Class