This example demonstrates how to create a new appointment for the time interval currently selected in the scheduler. The selected time interval is accessed via the SelectedInterval property, and the selected resource is accessed via the SelectedResource property. An appointment is added to the SchedulerStorage.Appointments collection of the scheduler's Storage.
AppointmentExamples.cs |
scheduler.Storage.Appointments.Clear();
scheduler.ActiveView.SetSelection(new TimeInterval(DateTime.Now, new TimeSpan(2, 40, 0)), scheduler.ActiveView.GetResources()[1]);
scheduler.GroupType = SchedulerGroupType.Resource;
Appointment apt = scheduler.Storage.CreateAppointment(AppointmentType.Normal);
apt.Start = scheduler.SelectedInterval.Start;
apt.End = scheduler.SelectedInterval.End;
apt.ResourceId = scheduler.SelectedResource.Id;
scheduler.Storage.Appointments.Add(apt);
|
AppointmentExamples.vb |
' Delete all appointments.
scheduler.Storage.Appointments.Clear()
' Select time interval
scheduler.ActiveView.SetSelection(New TimeInterval(Date.Now, New TimeSpan(2, 40, 0)), scheduler.ActiveView.GetResources()(1))
' Group by resource.
scheduler.GroupType = SchedulerGroupType.Resource
' Create a new appointment.
Dim apt As Appointment = scheduler.Storage.CreateAppointment(AppointmentType.Normal)
' Set the appointment's time interval to the selected time interval.
apt.Start = scheduler.SelectedInterval.Start
apt.End = scheduler.SelectedInterval.End
' Set the appointment's resource to the resource which contains
' the currently selected time interval.
apt.ResourceId = scheduler.SelectedResource.Id
' Add the new appointment to the appointment collection.
scheduler.Storage.Appointments.Add(apt)
|