windowsforms-devexpress-dot-xtrascheduler-dot-schedulerdatastorage-dot-createappointment-x28-devexpress-dot-xtrascheduler-dot-appointmenttype-x29.md
Creates an appointment of the specified type.
Namespace : DevExpress.XtraScheduler
Assembly : DevExpress.XtraScheduler.v25.2.dll
NuGet Package : DevExpress.Win.Scheduler
public Appointment CreateAppointment(
AppointmentType type
)
Public Function CreateAppointment(
type As AppointmentType
) As Appointment
| Name | Type | Description |
|---|---|---|
| type | AppointmentType |
An AppointmentType enumeration value specifying the type of the created appointment.
|
| Type | Description |
|---|---|
| Appointment |
A newly created Appointment object.
|
Use the CreateAppointment method to create an appointment of the specified type. This method also creates all the required custom fields and adds it to the appointment’s CustomFieldCollection, available via the PersistentObject.CustomFields property. To add custom fields to the appointment manually use the PersistentObjectStorage<T>.CreateCustomFields method.
Subsequently use the AppointmentDataStorage.Add method to add a newly created appointment to the storage.
The following code illustrates how to add multiple appointments in code.
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();
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()
The following code snippets (auto-collected from DevExpress Examples) contain references to the CreateAppointment(AppointmentType) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-scheduler-create-appointments-on-reminder-alert/CS/ReminderCustomActions/Form1.cs#L49
// Create a new appointment.
Appointment app = schedulerDataStorage1.CreateAppointment(AppointmentType.Normal);
app.Subject = "Created on alert from appointment w/Price = " + e.AlertNotifications[0].ActualAppointment.CustomFields["CustomPrice"];
winforms-scheduler-data-binding-entity-framework-code-first/CS/XtraSchedulerEFTest/Form1.cs#L71
{
Appointment apt = schedulerStorage1.CreateAppointment(AppointmentType.Normal);
apt.Start = DateTime.Now;
winforms-scheduler-hit-testing/CS/HitTest/Form1.cs#L24
{
Appointment apt = schedulerStorage1.CreateAppointment(AppointmentType.Normal);
apt.Subject = "Presentation";
winforms-scheduler-import-google-calendar/CS/GoogleCalendarExample/RecurrencePatternParser.cs#L38
Appointment pattern = Storage.CreateAppointment(AppointmentType.Pattern);
pattern.Start = start;
winforms-scheduler-drag-drop-appointments-from-grid/CS/T179722/Form1.cs#L102
foreach (AppointmentExchangeData item in (IList)data) {
var apt = this.schedulerStorage.CreateAppointment(AppointmentType.Normal);
apt.Subject = item.Subject;
winforms-scheduler-create-appointments-on-reminder-alert/VB/ReminderCustomActions/Form1.vb#L51
' Create a new appointment.
Dim app As Appointment = schedulerDataStorage1.CreateAppointment(AppointmentType.Normal)
app.Subject = "Created on alert from appointment w/Price = " & e.AlertNotifications(0).ActualAppointment.CustomFields("CustomPrice").ToString()
winforms-scheduler-data-binding-entity-framework-code-first/VB/XtraSchedulerEFTest/Form1.vb#L67
Private Sub btnCreateAppointment_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnCreateAppointment.Click
Dim apt As Appointment = schedulerStorage1.CreateAppointment(AppointmentType.Normal)
apt.Start = Date.Now
winforms-scheduler-drag-drop-appointments-from-grid/VB/T179722/Form1.vb#L87
For Each item As T179722.AppointmentExchangeData In CType(data, System.Collections.IList)
Dim apt = Me.schedulerStorage.CreateAppointment(DevExpress.XtraScheduler.AppointmentType.Normal)
apt.Subject = item.Subject
winforms-scheduler-bind-to-xpo/VB/XPO_XtraScheduler_Simple_Example/Form1.vb#L40
If schedulerDataStorage1.Appointments.Count = 0 Then
Dim apt1 As Appointment = schedulerDataStorage1.CreateAppointment(AppointmentType.Normal)
apt1.Start = Date.Now
See Also