Back to Devexpress

Business Objects

windowsforms-9606-controls-and-libraries-scheduler-data-binding-data-sources-business-objects.md

latest3.5 KB
Original Source

Business Objects

  • Nov 13, 2018
  • 3 minutes to read

The Scheduler can be bound to a collection of custom objects. This document contains a brief overview of collection types and contains an example of code that is used to implement appointment and resource objects.

A Scheduler Storage can be bound to a System.ComponentModel.BindingList<T> class instance (a generic collection that supports data binding), or a System.Collections.ObjectModel.ObservableCollection<T> class instance (a dynamic data collection that provides notifications). When you consider the type of item to use in a collection, make sure that its properties can be mapped to the Scheduler Storage fields in a straightforward way (i.e., the property value type must correspond to the data type used in the mapping). This rule prohibits the use of the System.Collections.ObjectModel.ObservableCollection<Appointment> collection as the data source because the mapping AppointmentMappingInfo.RecurrenceInfo requires a mapped field of type string , not the RecurrenceInfo data type. Review the code snippet below for information on data types required for specific mappings.

The following code demonstrates how to implement appointment and resource objects.

View Example

csharp
public class CustomAppointment
{
    public DateTime StartTime { get; set; }
    public DateTime EndTime { get; set; }
    public string Subject { get; set; }
    public int Status { get; set; }
    public string Description { get; set; }
    public int Label { get; set; }
    public string Location { get; set; }
    public bool AllDay { get; set; }
    public int EventType { get; set; }
    public string RecurrenceInfo { get; set; }
    public string ReminderInfo { get; set; }
    public object OwnerId { get; set; }
}
public class CustomResource {
    public string Name { get; set; }
    public int ResID { get; set; }
    public Color ResColor { get; set; }
    // Set the SchedulerStorage.Resources.ColorSaving property to ColorSavingType.Color to display resources using the specified color. 
}
vb
Public Class CustomAppointment
    Public Property StartTime() As Date
    Public Property EndTime() As Date
    Public Property Subject() As String
    Public Property Status() As Integer
    Public Property Description() As String
    Public Property Label() As Integer
    Public Property Location() As String
    Public Property AllDay() As Boolean
    Public Property EventType() As Integer
    Public Property RecurrenceInfo() As String
    Public Property ReminderInfo() As String
    Public Property OwnerId() As Object
End Class
Public Class CustomResource
    Public Property Name() As String
    Public Property ResID() As Integer
    Public Property ResColor() As Color
    ' Set the SchedulerStorage.Resources.ColorSaving property to ColorSavingType.Color to display resources using the specified color. 
End Class

Note

Do not implement a property in your custom object that returns a collection. You should instead implement a container class that has a property to get and set the collection, and use this class in the corresponding custom object property instead.