gpt4 book ai didi

c# - 将重复应用于代码隐藏的约会(DevExpress Scheduler Control)

转载 作者:太空宇宙 更新时间:2023-11-03 13:51:29 25 4
gpt4 key购买 nike

我正在使用 devExpress scheduler control .请注意,我试图通过以下代码实现的是在代码隐藏的约会中添加重复。在此示例中,我在创建新约会时这样做。

我的窗口包含一个调度程序控件:

<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
xmlns:dxsch="http://schemas.devexpress.com/winfx/2008/xaml/scheduler">

<dxsch:SchedulerControl Name="schedulerControl1" />

</Window>

背后的代码包括:

using System.Windows;
using DevExpress.XtraScheduler;

namespace WpfApplication1
{
public partial class MainWindow : Window
{
public MainWindow() // Constructor
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
}

void MainWindow_Loaded(object sender, RoutedEventArgs e) // Fires when window loads
{
schedulerControl1.Storage.AppointmentsInserted += new PersistentObjectsEventHandler(Storage_AppointmentsInserted);
}

void Storage_AppointmentsInserted(object sender, PersistentObjectsEventArgs e) // fires when a new appointment is added
{
Appointment addedAppointment = null;
foreach (Appointment item in e.Objects)
addedAppointment = item;

/*
I want to set the reinsurance info in here!
I cant because RecuranceInfo = null!
*/
addedAppointment.RecurrenceInfo.Type = RecurrenceType.Hourly; // <- App Crashes
}
}
}

我不想绑定(bind)控件的重复属性。

换句话说 如果我可以创建一个从今天下午 2 点开始并每天重复且没有结束日期的约会,那就太好了。我如何才能在代码隐藏中创建该约会?

最佳答案

答案在此链接中:http://documentation.devexpress.com/#WindowsForms/CustomDocument6201

基本上我必须这样做:

        Appointment apt = schedulerControl1.Storage.CreateAppointment(AppointmentType.Pattern);
apt.Start = DateTime.Now;
apt.End = apt.Start.AddHours(2);
apt.Subject = "My Subject";
apt.Location = "My Location";
apt.Description = "My Description";

apt.RecurrenceInfo.Type = RecurrenceType.Daily;

schedulerControl1.Storage.AppointmentStorage.Add(apt);

关于c# - 将重复应用于代码隐藏的约会(DevExpress Scheduler Control),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13574622/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com