20th April 2015

DevExpress XAF - Scheduler Control Change Event Display Text

DevExpress XAF - Scheduler Control Change Event Display Text

By default when using the Win Scheduler List Editor List Editor Type when viewing your Events using the Scheduler Control, the time of the Event will be shown along with the Subject and Location of your event, as seen below.



It may be required for the event preview within the Scheduler Control to show more information or different information about the event, the code snippet below examples changing the preview text to a custom field against our event class, it needs to be implemented within a View Controller in the Module.Win project.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Scheduler.Win;
using DevExpress.XtraScheduler;
 
/// <summary>
/// Scheduler View Controller
/// </summary>
public partial class SchedulerViewController : ObjectViewController<ListView, MyEventClass>

/// <summary> /// Initializes a new instance of the <see cref="SchedulerViewController"/> class. /// </summary> public SchedulerViewController()

this.InitializeComponent(); this.RegisterActions(this.components);

/// <summary> /// Called when [view controls created]. /// </summary> protected override void OnViewControlsCreated()

base.OnViewControlsCreated(); SchedulerListEditor listEditor = View.Editor as SchedulerListEditor; if (listEditor != null)

SchedulerControl scheduler = listEditor.SchedulerControl; if (scheduler != null)

scheduler.InitAppointmentDisplayText += new AppointmentDisplayTextEventHandler(this.SchedulerControl_InitAppointmentDisplayText);

/// <summary> /// Handles the AppointmentDisplayText event of the SchedulerControl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="AppointmentDisplayTextEventArgs"/> instance containing the event data.</param> private void SchedulerControl_InitAppointmentDisplayText(object sender, AppointmentDisplayTextEventArgs e)

MyEventClass event = this.ObjectSpace.GetObjectByKey<MyEventClass>(e.Appointment.Id); if (event != null)

e.Text = string.Concat(event.MyCustomPreviewField);

The screenshot below shows how the above code snippet alters the event preview at runtime.



Fill in this quick form and discover your digital future
Choose your interests:

Where to find us

We'd love to welcome you into our office! We're only 20 miles north of Peterborough, conveniently just off the A16.

Carver House
Apex Court, Elsoms Way
Pinchbeck
Lincolnshire
PE11 3UL