Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

RecurrenceControlBase Class

A base class for recurrence controls available in the XtraScheduler library.

Namespace: DevExpress.XtraScheduler.UI

Assembly: DevExpress.XtraScheduler.v24.2.dll

NuGet Package: DevExpress.Win.Scheduler

#Declaration

[ComVisible(false)]
public class RecurrenceControlBase :
    XtraUserControl,
    IBatchUpdateable,
    IBatchUpdateHandler

#Remarks

This class implements the common functionality used by recurrence date-time controls. You should use this base class to create custom descendant recurrence controls.

The following properties and methods are specific for the RecurrenceControlBase:

#Example

This example shows how you can implement a custom recurrence control and use it in your appointment editing form. A control that allows you to specify hourly recurrence is created by inheriting from the RecurrenceControlBase class. A custom form used to set the Appointment.RecurrenceInfo property is displayed instead of the default appointment editing form. To accomplish this, the SchedulerControl.EditAppointmentFormShowing event is handled.

using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.UI;
using System;

namespace E558
{
    public partial class XtraForm1 : AppointmentRecurrenceForm
    {
        public XtraForm1(Appointment pattern, FirstDayOfWeek fdow, AppointmentFormController afc)
            : base(pattern, fdow, afc)
        {
            //InitializeComponent();
            checkEdit1.Tag = RecurrenceType.Hourly;
            UnsubscribeRecurrenceTypeControlsEvents();
            SubscribeRecurrenceTypeControlsEvents();
            SetRecurrenceType(this.GetRecurrenceType());
        }

        protected override void InitializeControls(FirstDayOfWeek firstDayOfWeek) {
            InitializeComponent();
            base.InitializeControls(firstDayOfWeek);
        }

        protected override void SubscribeRecurrenceTypeControlsEvents()
        {
            base.SubscribeRecurrenceTypeControlsEvents();
            if(checkEdit1 != null)
                checkEdit1.EditValueChanged += new EventHandler(this.chkRecurrenceTypeChanged);
        }
        protected override void UnsubscribeRecurrenceTypeControlsEvents()
        {
            base.UnsubscribeRecurrenceTypeControlsEvents();
            if (checkEdit1 != null)
                checkEdit1.EditValueChanged -= new EventHandler(this.chkRecurrenceTypeChanged);
        }
        protected override void ChangeCurrentRecurrenceControl()
        {
            if (this.CurrentRecurrenceControl != null)
            {
                this.CurrentRecurrenceControl.Visible = false;
            }
            switch (this.GetRecurrenceType())
            {
                case RecurrenceType.Daily:
                    this.CurrentRecurrenceControl = this.dailyRecurrenceControl1;
                    break;

                case RecurrenceType.Weekly:
                    this.CurrentRecurrenceControl = this.weeklyRecurrenceControl1;
                    break;

                case RecurrenceType.Monthly:
                    this.CurrentRecurrenceControl = this.monthlyRecurrenceControl1;
                    break;
                case RecurrenceType.Hourly:
                    this.CurrentRecurrenceControl = this.hourRecurrenceControl1;
                    break;

                default:
                    this.CurrentRecurrenceControl = this.yearlyRecurrenceControl1;
                    break;
            }

            this.CurrentRecurrenceControl.Visible = true;

        }
        protected override void SetRecurrenceType(RecurrenceType type)
        {
            if (type == RecurrenceType.Hourly && checkEdit1 != null)
            {
                    checkEdit1.Checked = true;
                    return;
            }
                base.SetRecurrenceType(type);
        }
    }
}
See Also