This task is going to guide you on using OpenAccess for accessing data with the RadScheduler windows forms control. Before reading this article refer to the general use of data providers for RadScheduler in the following documentation topic.
Having a sample models for the RadScheduler like the one in the following diagram there are few steps that should be accomplished before using the scheduler interactively in a windows forms application.
1. Drag an “ObjectProvider” component called “ObjectProviderAppointments” from the toolbox and configure it so that it provides representation for the “MyAppointment” objects in the application.
2. Add an “ObjectView” called “ObjectViewAppointments” which has its “ObjectProvider” property set to the object provider created in the previous step and the root type to the MyAppointment persistent class.
3. Do steps 1 and 2 for the MyResource persistent class which represents the resources used in an appointment - create “ObjectProviderResources” and “ObjectViewResources”.
4. Set the property UsePrivateObjectContext of both object providers to false. You can do that in the design time by un-checking the “Use private Object Context” checkbox. That way both object providers will use the same instance of an object scope to manipulate their data. The reason for that is to be able to interact between objects from both providers e.g. an appointment from “ObjectProviderAppointments” uses resource from “ObjectViewResources”.
5. Drag a RadScheduler from the Visual Studio toolbox on the form.
6. In the code-behind we should write the following method that binds the RadScheduler to use our object views as datasources for the appointments and resources.
private void BindToOpenAccessObjects()
SchedulerBindingDataSource dataSource = new SchedulerBindingDataSource();
AppointmentMappingInfo appointmentMappingInfo = new AppointmentMappingInfo();
appointmentMappingInfo.Start = "Start";
appointmentMappingInfo.End = "End";
appointmentMappingInfo.Summary = "Subject";
appointmentMappingInfo.Description = "Description";
appointmentMappingInfo.Location = "Location";
appointmentMappingInfo.Resources = "Resources";
appointmentMappingInfo.ResourceId = "Id";
dataSource.EventProvider.Mapping = appointmentMappingInfo;
dataSource.EventProvider.DataSource = this.objectViewAppointments;
ResourceMappingInfo resourceMappingInfo = new ResourceMappingInfo();
resourceMappingInfo.Id = "Id";
resourceMappingInfo.Name = "Name";
dataSource.ResourceProvider.Mapping = resourceMappingInfo;
dataSource.ResourceProvider.DataSource = this.objectViewResources;
this.radScheduler1.DataSource = dataSource;
Private Sub BindToOpenAccessObjects()
Dim dataSource As New SchedulerBindingDataSource()
Dim appointmentMappingInfo As New AppointmentMappingInfo()
appointmentMappingInfo.Start = "Start"
appointmentMappingInfo.End = "End"
appointmentMappingInfo.Summary = "Subject"
appointmentMappingInfo.Description = "Description"
appointmentMappingInfo.Location = "Location"
appointmentMappingInfo.Resources = "Resources"
appointmentMappingInfo.ResourceId = "Id"
dataSource.EventProvider.Mapping = appointmentMappingInfo
dataSource.EventProvider.DataSource = Me.objectViewAppointments
Dim resourceMappingInfo As New ResourceMappingInfo()
resourceMappingInfo.Id = "Id"
resourceMappingInfo.Name = "Name"
dataSource.ResourceProvider.Mapping = resourceMappingInfo
dataSource.ResourceProvider.DataSource = Me.objectViewResources
Me.radScheduler1.DataSource = dataSource
We should call this method after the initialization of the form.
Public Function Form1()
The only thing that is left is a button that saves all the changes done in the RadScheduler on its click event.
private void btnSave_Click(object sender, EventArgs e)
Private Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs)