Category / Section
How to add multi span appointment in WinForms ScheduleControl?
2 mins read
Add a multi-span appointment
To add span appointments in the WinForms ScheduleControl,
use ArrayListDataProvider as a binding source of the ScheduleControl. To
add multi-span appointments, use the AddSpanAppointment method.
C#
ArrayListDataProvider dataprovider = new Syncfusion.Schedule.ArrayListDataProvider();
IScheduleAppointment appointment = dataprovider.NewScheduleAppointment();
appointment = dataprovider.NewScheduleAppointment();
appointment.StartTime = DateTime.Now;
appointment.EndTime = DateTime.Now.AddDays(4);
appointment.AllDay = true;
appointment.Subject = "Party";
appointment.LabelValue = 1;
appointment.AllowResize = false;
appointment.AllowDrag = false;
//Convert the appointment as the recurrence schedule appointment
IRecurringScheduleAppointment recurrenceAppointment = appointment as IRecurringScheduleAppointment;
IScheduleAppointment appointment2 = dataprovider.NewScheduleAppointment();
appointment2 = dataprovider.NewScheduleAppointment();
appointment2.StartTime = DateTime.Now.AddDays(6);
appointment2.EndTime = DateTime.Now.AddDays(8);
appointment2.AllDay = true;
appointment2.Subject = "Meeting";
appointment2.LabelValue = 3;
appointment2.AllowResize = false;
appointment2.AllowDrag = false;
//Convert the appointment as the recurrence schedule appointment
IRecurringScheduleAppointment recurrenceAppointment2 = appointment2 as IRecurringScheduleAppointment;
//Add the multi-span day appointment to the schedule control
this.scheduleControl1.AddSpanAppointment(recurrenceAppointment, dataprovider);
this.scheduleControl1.AddSpanAppointment(recurrenceAppointment2, dataprovider);
this.scheduleControl1.DataSource = dataprovider;
VB
Dim dataprovider As ArrayListDataProvider = New Syncfusion.Schedule.ArrayListDataProvider()
Dim appointment As IScheduleAppointment = dataprovider.NewScheduleAppointment()
appointment = dataprovider.NewScheduleAppointment()
appointment.StartTime = DateTime.Now
appointment.EndTime = DateTime.Now.AddDays(4)
appointment.AllDay = True
appointment.Subject = "Party"
appointment.LabelValue = 1
appointment.AllowResize = False
appointment.AllowDrag = False
'Convert the appointment as the recurrence schedule appointment
Dim recurrenceAppointment As IRecurringScheduleAppointment = TryCast(appointment, IRecurringScheduleAppointment)
Dim appointment2 As IScheduleAppointment = dataprovider.NewScheduleAppointment()
appointment2 = dataprovider.NewScheduleAppointment()
appointment2.StartTime = DateTime.Now.AddDays(6)
appointment2.EndTime = DateTime.Now.AddDays(8)
appointment2.AllDay = True
appointment2.Subject = "Meeting"
appointment2.LabelValue = 3
appointment2.AllowResize = False
appointment2.AllowDrag = False
'Convert the appointment as the recurrence schedule appointment
Dim recurrenceAppointment2 As IRecurringScheduleAppointment = TryCast(appointment2, IRecurringScheduleAppointment)
'Add the multi-span day appointment to the schedule control
Me.scheduleControl1.AddSpanAppointment(recurrenceAppointment, dataprovider)
Me.scheduleControl1.AddSpanAppointment(recurrenceAppointment2, dataprovider)
Me.scheduleControl1.DataSource = dataprovider
MultiSpan appointments as shown in the screenshot below
Sample Links: