我正在使用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
}
}
}
我不想绑定控件的重复属性。
换句话说,如果我可以创建一个今天下午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/