windowsforms-114687-controls-and-libraries-scheduler-examples-labels-and-statuses-how-to-add-custom-labels-and-statuses.md
The following code snippet implements the AddCustomLabelsAndStatuses method that adds custom appointment labels and statuses.
using DevExpress.XtraScheduler;
public Form1() {
InitializeComponent();
AddCustomLabelsAndStatuses(schedulerControl);
}
void AddCustomLabelsAndStatuses(SchedulerControl schedulerControl) {
// Define custom label metadata.
var issues = new Dictionary<string, Color> {
{ "Consultation", Color.Ivory },
{ "Treatment", Color.Pink },
{ "X-Ray", Color.Plum }
};
// Define custom status metadata.
var paymentStatuses = new Dictionary<string, Color> {
{ "Paid", Color.Green },
{ "Unpaid", Color.Red }
};
// Add custom appointment labels.
IAppointmentLabelStorage labelStorage = schedulerControl.DataStorage.Appointments.Labels;
foreach (var issue in issues) {
IAppointmentLabel label = labelStorage.CreateNewLabel(labelStorage.Count, issue.Key);
label.SetColor(issue.Value);
labelStorage.Add(label);
}
// Add custom appointment statuses.
IAppointmentStatusStorage statusStorage = schedulerControl.DataStorage.Appointments.Statuses;
foreach (var status in paymentStatuses) {
IAppointmentStatus appStatus = statusStorage.CreateNewStatus(statusStorage.Count, status.Key, status.Key);
appStatus.SetBrush(new SolidBrush(status.Value));
statusStorage.Add(appStatus);
}
}
Imports DevExpress.XtraScheduler
Imports System.Drawing
Public Class Form1
Public Sub New()
InitializeComponent()
AddCustomLabelsAndStatuses(schedulerControl)
End Sub
Private Sub AddCustomLabelsAndStatuses(schedulerControl As SchedulerControl)
' Define custom label metadata.
Dim issues As New Dictionary(Of String, Color) From {
{"Consultation", Color.Ivory},
{"Treatment", Color.Pink},
{"X-Ray", Color.Plum}
}
' Define custom status metadata.
Dim paymentStatuses As New Dictionary(Of String, Color) From {
{"Paid", Color.Green},
{"Unpaid", Color.Red}
}
' Add custom appointment labels.
Dim labelStorage As IAppointmentLabelStorage = schedulerControl.DataStorage.Appointments.Labels
For Each issue In issues
Dim label As IAppointmentLabel = labelStorage.CreateNewLabel(labelStorage.Count, issue.Key)
label.SetColor(issue.Value)
labelStorage.Add(label)
Next
' Add custom appointment statuses.
Dim statusStorage As IAppointmentStatusStorage = schedulerControl.DataStorage.Appointments.Statuses
For Each status In paymentStatuses
Dim appStatus As IAppointmentStatus = statusStorage.CreateNewStatus(statusStorage.Count, status.Key, status.Key)
appStatus.SetBrush(New SolidBrush(status.Value))
statusStorage.Add(appStatus)
Next
End Sub
End Class