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的使用的更多相关文章

  1. TcxScheduler的使用2

    DevExpress 行事历(Scheduler)的常用属性.事件和方法 参考资料来源:附带的ExpressScheduler 2  Demo, 如想了解更多可以查看Demo. 一.TcxSchedu ...

  2. DevExpress 行事历(Scheduler)的常用属性、事件和方法

    一.TcxScheduler[TcxScheduler常用属性]1.Storage    - 邦定一个Storage为Scheduler显示提供数据 2.DateNavigate.ColCount   ...

随机推荐

  1. P4867 Gty的二逼妹子序列

    题目描述 Autumn和Bakser又在研究Gty的妹子序列了!但他们遇到了一个难题. 对于一段妹子们,他们想让你帮忙求出这之内美丽度∈[a,b]的妹子的美丽度的种类数. 为了方便,我们规定妹子们的美 ...

  2. Getting logback and slf4j to work in JBoss AS 7

    As usual, it has to do with classloading and that JBoss internally also uses slf4j and logback. As e ...

  3. CentOS7单节点部署redis主从复制和sentinel

    准备一台机器,系统版本为CentOS7. 部署redis 1.下载软件包 # wget http://download.redis.io/releases/redis-3.2.8.tar.gz 2.解 ...

  4. DUBBO - 分布式框架

    http://dubbo.io/ http://dubbo.io/User+Guide-zh.htm#UserGuide-zh-%E5%85%A5%E9%97%A8

  5. Java之Junit和反射

    Junit,反射 Junit 1.测试的分类: 黑盒测试 : 不需要写代码,给输入值,看程序是否能够输出期望的值. 白盒测试 : 需要进行代码的编写,关注的是程序的具体流程. 2.使用步骤(方法类的命 ...

  6. 解题:NOI 1999 生日蛋糕

    题面 裸的搜索题,就说剪枝(注:nw->noww->当前,res->rest->剩余): 1.想达到$Nπ$的体积,那么半径一开始最多也就$sqrt(n)$了,再大就超了... ...

  7. CentOS 6.5下Squid代理服务器的安装与配置

    1.1   缓存代理概述 作为应用层的代理服务器软件,squid主要提供缓存加速,应用层过滤控制的功能. 1.  代理的工作机制 当客户机通过代理来请求web页面时,指定的代理服务器会先检查自己的缓存 ...

  8. Django JSON 时间

    在views.py中导入: from django.core.serializers.json import DjangoJSONEncoder 在返回JSON数据时调用: return HttpRe ...

  9. JAVA 线程池基本总结

    合理利用线程池能够带来三个好处. 第一:降低资源消耗.通过重复利用已创建的线程降低线程创建和销毁造成的消耗. 第二:提高响应速度.当任务到达时,任务可以不需要等到线程创建就能立即执行. 第三:提高线程 ...

  10. python 套接字之select poll epoll

    python下的select模块使用 以及epoll与select.poll的区别 先说epoll与select.poll的区别(总结) select, poll, epoll 都是I/O多路复用的具 ...