corelibraries-devexpress-dot-xtrascheduler-dot-persistentobject-ea79ab9c.md
Gets the collection of custom fields bound to the persistent object.
Namespace : DevExpress.XtraScheduler
Assembly : DevExpress.XtraScheduler.v25.2.Core.dll
NuGet Package : DevExpress.Scheduler.Core
[Browsable(false)]
public CustomFieldCollection CustomFields { get; }
<Browsable(False)>
Public ReadOnly Property CustomFields As CustomFieldCollection
| Type | Description |
|---|---|
| CustomFieldCollection |
A CustomFieldCollection object representing the collection of the persistent object’s custom fields.
|
Use this property to access the custom fields bound to this persistent object (appointment, resource or AppointmentDependency). Note that the custom fields are created and bound by the CustomFieldMappingCollectionBase<T> object returned via the AppointmentStorage.CustomFieldMappings or ResourceStorage.CustomFieldMappings property.
The code sample below illustrates how to create an appointment with a custom field and use this field in the SchedulerDataStorage.FilterAppointment event to hide appointments which meet certain criteria.
To define a custom field, create a new custom field mapping and add it to the collection of custom mappings using the CustomFieldMappingCollectionBase<T>.Add method. If the Scheduler is not bound to a data source, specify any non-empty string as the data field name.
Create an appointment using the SchedulerDataStorage.CreateAppointment method (so the newly created custom field mappings will be preserved for a new appointment). Set the value for the custom field and add the appointment to the SchedulerDataStorage.Appointments collection.
In the SchedulerDataStorage.FilterAppointment event handler, check the value of the custom field to set e.Cancel to true and hide this appointment.
scheduler.Storage.Appointments.Clear();
// Handle the FilterAppointment event to display appointments by some criteria.
scheduler.Storage.FilterAppointment += Storage_FilterAppointment;
scheduler.DayView.TopRowTime = TimeSpan.FromHours(DateTime.Now.Hour);
// Add mapping to create a custom field.
// If Scheduler is bound to data, the string "DataFieldOne" should match the field name in the data source.
// For unbound Scheduler, the data field name is required but not used.
scheduler.Storage.Appointments.CustomFieldMappings.Add(new
AppointmentCustomFieldMapping("PropertyOne", "DataFieldOne"));
Appointment apt1 = scheduler.Storage.CreateAppointment(AppointmentType.Normal,
DateTime.Now, new TimeSpan(1, 0, 0), "Visible Appointment");
apt1.CustomFields["PropertyOne"] = "Visible";
scheduler.Storage.Appointments.Add(apt1);
Appointment apt2 = scheduler.Storage.CreateAppointment(AppointmentType.Normal,
DateTime.Now.AddHours(2), new TimeSpan(0, 30, 0), "Hidden Appointment");
apt2.CustomFields["PropertyOne"] = "Hidden";
scheduler.Storage.Appointments.Add(apt2);
static void Storage_FilterAppointment(object sender, PersistentObjectCancelEventArgs e) {
e.Cancel = ((Appointment)e.Object).CustomFields["PropertyOne"].ToString() == "Hidden";
}
scheduler.Storage.Appointments.Clear()
' Handle the FilterAppointment event to display appointments by some criteria.
AddHandler scheduler.Storage.FilterAppointment, AddressOf Storage_FilterAppointment
scheduler.DayView.TopRowTime = TimeSpan.FromHours(Date.Now.Hour)
' Add mapping to create a custom field.
' If Scheduler is bound to data, the string "DataFieldOne" should match the field name in the data source.
' For unbound Scheduler, the data field name is required but not used.
scheduler.Storage.Appointments.CustomFieldMappings.Add(New AppointmentCustomFieldMapping("PropertyOne", "DataFieldOne"))
Dim apt1 As Appointment = scheduler.Storage.CreateAppointment(AppointmentType.Normal, Date.Now, New TimeSpan(1, 0, 0), "Visible Appointment")
apt1.CustomFields("PropertyOne") = "Visible"
scheduler.Storage.Appointments.Add(apt1)
Dim apt2 As Appointment = scheduler.Storage.CreateAppointment(AppointmentType.Normal, Date.Now.AddHours(2), New TimeSpan(0, 30, 0), "Hidden Appointment")
apt2.CustomFields("PropertyOne") = "Hidden"
scheduler.Storage.Appointments.Add(apt2)
Private Shared Sub Storage_FilterAppointment(ByVal sender As Object, ByVal e As PersistentObjectCancelEventArgs)
e.Cancel = CType(e.Object, Appointment).CustomFields("PropertyOne").ToString() = "Hidden"
End Sub
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomFields property.
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-print-appointments-using-reports/CS/PrintingViaReports/Task.cs#L57
public string CustomText {
get { return (string)base.CustomFields["CustomTextField"]; }
set { base.CustomFields["CustomTextField"] = value; }
winforms-scheduler-print-appointments-using-reports/VB/PrintingViaReports/Task.vb#L62
Get
Return CStr(MyBase.CustomFields("CustomTextField"))
End Get
See Also