【问题标题】:Cant use InitAppointmentImages event with extended Class不能将 InitAppointmentImages 事件与扩展类一起使用
【发布时间】:2014-07-02 10:34:26
【问题描述】:

我有一个 XtraScheduler,想在我的约会中显示一些图片。 DevExpress 知识库给我看这篇文章:https://documentation.devexpress.com/#windowsforms/DevExpressXtraSchedulerSchedulerControl_InitAppointmentImagestopic

他们描述了 InitAppointmentImages 事件,它看起来正是我正在搜索的内容,但我有一个问题。

InitAppointmentImages 事件的 EventArgs 给了我实际的约会。在我的项目中,我有一个从 Appointment 扩展的课程。此类用作 XtraScheduler (List) 的 DataSource。所以我认为我可以做到以下几点:

private void myCalendar_InitAppointmentImages(object sender, AppointmentImagesEventArgs e)
{
    MyClass obj = e.Appointment as MyClass;

    if (obj != null)
    {
        AppointmentImageInfo info = new AppointmentImageInfo();
        info.Image = MyImageCollection.Images[0];
        e.ImageInfoList.Add(info);
    }
}

但 obj 始终为空! :( 我无法理解,因为 MyClass 是从 Appointment 扩展而来的,而 DataSource 来自 MyClass 类型。这个层次结构工作正常表明这个例子正在工作:

    MyClass obj = (MyClass)MyCalendar.SelectedAppointments[0].GetSourceObject(MyStorage);

【问题讨论】:

    标签: c# winforms devexpress scheduler


    【解决方案1】:

    如果您使用它来获取您的 MyClass 对象:

    MyClass obj = (MyClass)MyCalendar.SelectedAppointments[0].GetSourceObject(MyStorage);
    

    你需要对e.Appointment做同样的事情:

    MyClass obj = e.Appointment.GetSourceObject(MyStorage) as MyClass;
    

    【讨论】:

    • 是的,这绝对是有道理的。谢谢:)
    猜你喜欢
    • 1970-01-01
    • 2016-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-30
    • 2014-10-21
    • 1970-01-01
    • 2020-10-21
    相关资源
    最近更新 更多