Back to Devexpress

AppointmentDataStorage.CreateAppointment(AppointmentType) Method

windowsforms-devexpress-dot-xtrascheduler-dot-appointmentdatastorage-dot-createappointment-x28-devexpress-dot-xtrascheduler-dot-appointmenttype-x29.md

latest3.7 KB
Original Source

AppointmentDataStorage.CreateAppointment(AppointmentType) Method

Creates an appointment of the specified type.

Namespace : DevExpress.XtraScheduler

Assembly : DevExpress.XtraScheduler.v25.2.dll

NuGet Package : DevExpress.Win.Scheduler

Declaration

csharp
public Appointment CreateAppointment(
    AppointmentType type
)
vb
Public Function CreateAppointment(
    type As AppointmentType
) As Appointment

Parameters

NameTypeDescription
typeAppointmentType

An AppointmentType enumeration value specifying the type of the created appointment.

|

Returns

TypeDescription
Appointment

A newly created Appointment object.

|

Remarks

Use the CreateAppointment method to create an appointment. The method is equivalent to the SchedulerDataStorage.CreateAppointment method.

Subsequently use the AppointmentDataStorage.Add method to add a newly created appointment to the storage.

csharp
Appointment apt = schedulerDataStorage.CreateAppointment(AppointmentType.Normal);
schedulerDataStorage.Appointments.Add(apt);
vb
Dim apt As Appointment = schedulerDataStorage.CreateAppointment(AppointmentType.Normal) 
schedulerDataStorage.Appointments.Add(apt)

The following code illustrates how to add multiple appointments in code.

csharp
int count = 10;
Appointment[] AppArray = new Appointment[count];
AppointmentCollection AppCollection = new AppointmentCollection();
for (int i=1; i<=count; i++) {
    Appointment newApp = schedulerControl.DataStorage.CreateAppointment(AppointmentType.Normal);
    newApp.Start = DateTime.Now.AddMinutes(count);
    newApp.End = DateTime.Now.AddMinutes(count * 2);
    AppCollection.Add(newApp);
}
AppCollection.CopyTo(AppArray, 0);
schedulerControl.DataStorage.BeginUpdate();
schedulerControl.DataStorage.Appointments.AddRange(AppArray);
schedulerControl.DataStorage.EndUpdate();
vb
Dim count As Integer = 10
Dim AppArray(count - 1) As Appointment
Dim AppCollection As New AppointmentCollection()
For i As Integer = 1 To count
    Dim newApp As Appointment = schedulerControl.DataStorage.CreateAppointment(AppointmentType.Normal)
    newApp.Start = Date.Now.AddMinutes(count)
    newApp.End = Date.Now.AddMinutes(count * 2)
    AppCollection.Add(newApp)
Next i
AppCollection.CopyTo(AppArray, 0)
schedulerControl.DataStorage.BeginUpdate()
schedulerControl.DataStorage.Appointments.AddRange(AppArray)
schedulerControl.DataStorage.EndUpdate()

See Also

AppointmentDataStorage Class

AppointmentDataStorage Members

DevExpress.XtraScheduler Namespace