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 ...
随机推荐
- js浏览器缩放提示
data() { return { instance: null, isZoomOpen: false }; }, mounted() { const that = this; this.isZoom ...
- 题解 CF1005A 【Tanya and Stairways】
楼上别说这个题水,这个题可能还真有不知道的知识点. 看到这个题,想到刚学的单调栈. 单调栈? 单调栈和单调队列差不多,但是我们只用到它的栈顶. 单调,意思就是一直递增或者递减. 这跟这个题有什么关系? ...
- cmake 常用变量和常用环境变量查表手册
cmake 常用变量和常用环境变量查表手册 一,cmake 变量引用的方式: 前面我们已经提到了,使用${}进行变量的引用.在 IF 等语句中,是直接使用变量名而不通过${}取值 二,cmake 自定 ...
- BZOJ 4421: [Cerc2015] Digit Division
4421: [Cerc2015] Digit Division Time Limit: 1 Sec Memory Limit: 512 MBSubmit: 348 Solved: 202[Subm ...
- BZOJ 4753 [Jsoi2016]最佳团体 | 树上背包 分数规划
BZOJ 4753 [Jsoi2016]最佳团体 | 树上背包 分数规划 又是一道卡精度卡得我头皮发麻的题-- 题面(--蜜汁改编版) YL大哥是24OI的大哥,有一天,他想要从\(N\)个候选人中选 ...
- POJ 3348 Cows | 凸包——童年的回忆(误)
想当年--还是邱神给我讲的凸包来着-- #include <cstdio> #include <cstring> #include <cmath> #include ...
- 【bzoj3832】Rally
Portal -->bzoj3832 Description 给你一个DAG,每条边长度都是\(1\),请找一个点满足删掉这个点之后剩余图中的最长路最短 Solution 这题的话感觉 ...
- 18华南理工校赛 K 小马哥的超级盐水
https://www.nowcoder.com/acm/contest/94/K sum(ai)/sum(bi) = x/y <=> sum(ai*yi-bi*x) = 0 跟这题有点类 ...
- RF - selenium - open browser
*** Settings ***Library Selenium2Library *** Test Cases ***Open baidu with Chrome Open Browser http: ...
- 优先队列:POJ No 3614 Sunscreen 贪心
Sunscreen Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6410 Accepted: 2239 Descrip ...