`
lovnet
  • 浏览: 6705312 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
文章分类
社区版块
存档分类
最新评论

DevExpress.XtraScheduler控件的使用方法一

阅读更多

花了两天时间,总算把XtraScheduler控件的使用方法大致搞明白了。由于这方面的中文资料特别少,所以把这方面的心得整理下来。

一、数据的读取和保存
1. 使用XML文档(参考Demo修改)
保存: schedulerStorage1.Appointments.Items.WriteXml("xmlFile.xml");
读取:
public static void FillStorageCollection(PersistentObjectCollection c, string xmlFile) {
using(Stream stream = new System.IO.FileStream(xmlFile, FileMode.Open, FileAccess.Read)
{
c.ReadXml(stream);
stream.Close();
}
}

public static void FillStorageData(SchedulerStorage storage) {
FillStorageCollection(storage.Appointments.Items, "XmlFile.xml");
}

在Form_Load中直接填充数据:FillStorageData(schedulerStorage1)就OK了。

二、使用数据表
TableName:【UserScheduler】
(1). ID Primary int
(2). UserName nvarchar(20) AllowNull
(3). AppAllDay bit AllowNull
(4). AppDescription text(16) AllowNull
(5). AppEnd datetime AllowNull
(6). AppLabel int AllowNull
(7). AppLocation varchar(100) AllowNull
(8). AppRecurrenceInfo xml AllowNull
(9). AppReminderInfo xml AllowNull
(10). AppResourceId int AllowNull
(11). AppStart datetime AllowNull
(12). AppStatus varchar(50) AllowNull
(13). AppSubject varchar(100) AllowNull
(14). AppType varchar(50) AllowNull
其中ID是自增类型, UserName是用户名,其余都是保存Appointment的相关信息。
AppRecurrenceInfo和AppReminderInfo分别用来保存循环和提醒信息,我用的数据库是SQLServer2005,采用的是XML数据类型,采用Text也没问题。

定义一个变量: DataSet ds = new DataSet();
读取数据:
schedulerStorage1.Appointments.Mappings.AllDay = "AppAllDay";
schedulerStorage1.Appointments.Mappings.Description = "AppDescription";
schedulerStorage1.Appointments.Mappings.End = "AppEnd";
schedulerStorage1.Appointments.Mappings.Label = "AppLabel";
schedulerStorage1.Appointments.Mappings.Location = "AppLocation";
schedulerStorage1.Appointments.Mappings.RecurrenceInfo = "AppRecurrenceInfo";
schedulerStorage1.Appointments.Mappings.ReminderInfo = "AppReminderInfo";
schedulerStorage1.Appointments.Mappings.ResourceId = "AppResourceId";
schedulerStorage1.Appointments.Mappings.Start = "AppStart";
schedulerStorage1.Appointments.Mappings.Status = "AppStatus";
schedulerStorage1.Appointments.Mappings.Subject = "AppSubject";
schedulerStorage1.Appointments.Mappings.Type = "AppType";

ds = ...........................;
schedulerStorage1.Appointments.DataSource = ds.Tables[0];

保存数据:
schedulerStorage1.Appointments.EndUpdate();
这样会把数据更新到DataSet,然后吧这个DataSet写回数据库就OK了。

三、schedulerStorage1.Resources的设置,和Appointment差不多,我直接使用了Demo上的方法。

四、弹出Appointments表单的汉化。
看XtraScheduler的源码,是直接使用Form做的。我直接在上面汉化,然后重新编译的。
比较好的办法是直接修改DevExpress.XtraScheduler.Localization,然后在Form中调用Localization里面的文字,这样汉化就比较方便了。呵呵,偶偷懒,没有去做。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics