DevExpress:自定义XAF调度程序列表视图显示文本

时间:2015-03-18 10:20:39

标签: devexpress scheduler xaf

我的XAF应用程序中有一个业务对象,它继承自标准的Scheduler'Event'类。在列表视图中,我得到默认的调度程序列表视图,其中框显示描述性文本。我想在这些框中显示其他文字。我环顾四周,发现了“ScheduleControl.InitAppointmentDisplayText”事件,但无法弄清楚如何在我的班级中实现它。

1 个答案:

答案 0 :(得分:0)

您可以在Module.Win项目的视图控制器中实现以下代码。

namespace Project.Module.Win.Controllers{

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Scheduler.Win;
using DevExpress.XtraScheduler;

public partial class SchedulerViewController : ObjectViewController<ListView, Project.Module.BusinessObjects.Event>
{
    public SchedulerViewController()
    {
        this.InitializeComponent();
        this.RegisterActions(this.components);
    }

    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);
            }
        }
    }

    private void SchedulerControl_InitAppointmentDisplayText(object sender, AppointmentDisplayTextEventArgs e)
    {       
        MyEventObject myEventObject = this.ObjectSpace.GetObjectByKey<MyEventObject>(e.Appointment.Id);

        if (myEventObject != null)
        {
            e.Text = string.Concat("Text Goes Here - ", myEventObject.FieldValue);
        }
    }
}