How to: Add Custom Labels and Statuses
- 2 minutes to read
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);
}
}