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. django-rest-swagger对API接口注释

    Swagger是一个API开发者的工具框架,用于生成.描述.调用和可视化RESTful风格的Web服务.总体目标是使客户端和文件系统服务器以同样的速度来更新,方法,参数和模型紧密集成到服务器端的代码中 ...

  2. MT【134】待定系数

    已知\(a,b>0\)且\(ab(a+b)=4\),求\(2a+b\)的最小值______. 解答:\(\sqrt{3}(2a+b)\ge(\sqrt{3}+1)a+b+(\sqrt{3}-1) ...

  3. 【刷题】洛谷 P4209 学习小组

    题目描述 共有n个学生,m个学习小组,每个学生只愿意参加其中的一些学习小组,且一个学生最多参加k个学习小组.每个学生参加学习小组财务处都收一定的手续费,不同的学习小组有不同的手续费.若有a个学生参加第 ...

  4. 【bzoj2555】 SubString

    http://www.lydsy.com/JudgeOnline/problem.php?id=2555 (题目链接) 题意 给出一个初始串,维护两个操作.在原串后面加入一个字符串:询问某个字符串在原 ...

  5. Java的容器类

    程序总是根据运行时才知道的某些条件去创建新对象.需要在任意时刻和任意位置创建任意数量的对象. 如果你想保存一组基本数据类型数据,建议使用数组,但是数组有固定的尺寸. 一般情况下,你在写程序时并不知道将 ...

  6. 解题:SCOI 2012 喵星球上的点名

    题面 初见广义SAM 建立广义SAM,每次把询问走一遍,最终走到节点的子树里的猫老师都被这次点名点到 这样DFS parent树打时间戳记录入栈出栈时间,把问题转化成一个序列问题:给一个若干种颜色构成 ...

  7. Chapter9(顺序容器) --C++Prime笔记

    PS:删除元素的成员函数并不检查其参数.在删除元素之前,程序员必须确保它们是存在的. 1.迭代器的范围是[begin,end)左闭右开. 2.对构成迭代器的要求: ①它们指向同一个容器中的元素或者容器 ...

  8. 怎样彻底卸载(删除)SQL server2000

    如何完全卸载SQL server 2000 一.卸载安装程序:找到电脑右下角的Windows开始按钮,找到控制面板——卸载程序. 找到server 2000的安装程序,并点击后面的卸载按钮.  是,确 ...

  9. Tomcat假死排查方案

    使用Tomcat作为Web服务器的时候偶尔会遇到Tomcat停止响应的情况,通过netstat查看端口情况会发现tomcat的端口出现大量的CLOSE_WAIT,此时Tomcat会停止响应前端请求,同 ...

  10. Web API: Security: Basic Authentication

    原文地址: http://msdn.microsoft.com/en-us/magazine/dn201748.aspx Custom HttpModule code: using System; u ...