TcxScheduler的使用
TcxScheduler有两种工作模式:
一、非绑定模式
非绑定模式下,数据被存储在文件系统中。要让scheduler工作在非绑定模式下,应使TcxScheduler.Storage属性绑定到TcxSchedulerStorage部件
。
考虑到用户在不同的资源下安排用户事件,分如下步骤:
1.定义不同的计划资源:
在TcxSchedulerStorageResources.itmes创建2个资源,分别为其命名并将TcxSchedulerStorageResourceItem.ResourceID属性设置为1和2。
2.在TCustomForm.OnCreate和TCustomForm.OnDestroy事件中:
procedure TUnboundForm.FormCreate(Sender: TObject);
const
DlgMsg = 'There was no file found';
FileName = 'c:\unbound.dat';
begin
if FileExists(FileName) then
// load the data from the file when the application starts up
Storage.LoadFromFile(FileName)
else
ShowMessage(DlgMsg);
end;
procedure TUnboundForm.FormDestroy(Sender: TObject; var Action: TCloseAction);
const
FileName = 'c:\unbound.dat';
begin
// save the data to the file when the application exits
Storage.SaveToFile(FileName);
end;
3.下面的代码演示如何安排用户事件:
with Storage.CreateEvent do
begin
// assign the newly created user event to the Nata Epelman resource
ResourceID := 2;
// specify the subject
Caption := 'Anniversary';
// this is the all-day event
AllDayEvent := True;
// synchronize with storage
Post;
end;
每个TcxSchedulerEvent实例代表最终用户的一个事件,对应TcxStorage的一个记录。
用户事件的开始与结束时间由TcxSchedulerEvent的start与finish属性(TDateTime类型,该类型的使用可参见http://masprb.blog.sohu.com/194187241.html)指定。
用户事件如果是全天事件,由TcxSchedulerEvent的AllDayEvent属性指定(Boolean类型)。
用户事件的标题、标签颜色、位置、细节、状态分别由TcxSchedulerEvent的Caption、LabelColor、Location、Message、State指定。
TcxSchedulerStorage.CreateEvent过程创建一个TcxSchedulerEvent实例。
绑定模式下,数据被存储在数据库系统中。要使scheduler工作在绑定模式下,应将TcxScheduler.Storage属性绑定到TcxSchedulerDBStorage部件。步骤如下:
1.创建两个用以存储数据的表SchedulerTable、SchedulerResourcesTable,结构如下:
create table schedulertable
(
ActualFinish int,
ActualStart int,
Caption varchar(255),
EventType int,
Finish datetime,
ID int,
LabelColor int,
Location varchar(255),
Message varchar(255),
Options int,
ParentID int,
RecurrentceIndex int,
RecurrenceInfo text,
ReminderDate datetime,
ReminderMinutesBeforeStart int,
RemminderResourcesData text,
ResourceID int,
Start datetime,
State int,
TaskCompleteField int,
TaskIndexField int,
TaskLinksField text,
TaskStatusField int
);
create table schedulerResourcesTable
(
ResourceID int,
ResourceColor int,
ResourceImageIndex int,
ResourceName varchar(255)
)
insert into schedulerResourcesTable(ResourceID,ResourceName) values(1,'日常工作计划');
insert into schedulerResourcesTable(ResourceID,ResourceName) values(2,'日常学习计划');
2.控件的使用
在窗体上分别放置2个DataSource与Table控件,如下图所示:

3.控件的设置
将cxSchedulerDBStorage的DataSource指向DS_Schduler,FieldNames中每个属性分别对应表中的相应字段。将cxSchedulerDBStorage的Resources的DataSource指向DS_Resource,ResourceColor、ResourceID、ResourceImageIndex、ResourceName分别指向表中相对应的字段。
4.创建user event的示例代码:
with SchedulerDBStorage.CreateEvent do
begin
ResourceID := 1; // assign the newly created user event to the Lesli Gritts resource
Caption := 'Birthday'; // specify the subject
AllDayEvent := True; // this is the all-day event
Post; // synchronize with storage
end;
TcxScheduler的使用的更多相关文章
- TcxScheduler的使用2
DevExpress 行事历(Scheduler)的常用属性.事件和方法 参考资料来源:附带的ExpressScheduler 2 Demo, 如想了解更多可以查看Demo. 一.TcxSchedu ...
- DevExpress 行事历(Scheduler)的常用属性、事件和方法
一.TcxScheduler[TcxScheduler常用属性]1.Storage - 邦定一个Storage为Scheduler显示提供数据 2.DateNavigate.ColCount ...
随机推荐
- 不记得oracle管理员密码,更改oracle sys密码的方法
1.确保下面两条满足 a. sqlnet.ora里 SQLNET.AUTHENTICATION_SERVICES = (NTS) 的配置是否存在,不存在加上这句: b. 你的os 用户是不是属于ora ...
- 【刷题】BZOJ 1969 [Ahoi2005]LANE 航线规划
Description 对Samuel星球的探险已经取得了非常巨大的成就,于是科学家们将目光投向了Samuel星球所在的星系--一个巨大的由千百万星球构成的Samuel星系. 星际空间站的Samuel ...
- 【BZOJ5252】林克卡特树(动态规划,凸优化)
[BZOJ5252]林克卡特树(动态规划,凸优化) 题面 BZOJ(交不了) 洛谷 题解 这个东西显然是随着断开的越来越多,收益增长速度渐渐放慢. 所以可以凸优化. 考虑一个和\(k\)相关的\(dp ...
- 一次lvs迁移记录
需求:从117.119.33.99迁移到122.14.206.125,lvs为dr模式,系统版本为debian7 1.安装lvs和keepalived # aptitude install -y ip ...
- 设计模式 (一)——策略模式(Strategy,行为型)
1.概述 使用设计模式可以提高代码的可复用性.可扩充性和可维护性.策略模式(Strategy Pattern)属于行为型模式,其做法是将类所需的行为或者算法一个个封装成单独的类,并将其作为类的数据成员 ...
- scala 的安装 与 IDEA安装使用
一.安装 scala 1.下载scala-2.11.8.msi 安装包, 首先去官网http://www.scala-lang.org/,然后点击导航栏的DOWNLOAD,进入下载链接:http: ...
- 个人在 laravel 开发中使用到的一些技巧(持续更新)
1.更高效率地查询:使用批量查询代替 foreach 查询(多次 io 操作转换为一次 io操作) 如果想要查看更详尽的介绍,可以看看这篇文章 什么是 N+1 问题,以及如何解决 Laravel 的 ...
- Chapter 6(树)
1.树的储存方式 //****************双亲表示法************************ #define Max_TREE_SIZE 100 typedef int TElem ...
- TIME_WAIT状态的一些总结
前言: TCP断开连接的四次握手中, 主动关闭连接的一方的TIME_WAIT状态尤为重要. 1:TCP连接的三次握手和断开的四次挥手 2:由上图可知 在主动关闭的一方, 会经历TIME_WAIT状态, ...
- java8 新特性 Stream
1. Stream初体验 我们先来看看Java里面是怎么定义Stream的: A sequence of elements supporting sequential and parallel agg ...