Demo学习: CalendarPanel

CalendarPane

学习CalendarPanel控件的常用事件。

DayClick(...) //点击日期块空白部分触发
EventClick(...) //点击日期块上事件触发
RangeSelect(...) //选择多个日期触发

procedure TMainForm.UniCalendarPanel1DayClick(Sender: TUniCalendarPanel;
  ADate: TDateTime; Allday: Boolean);
begin
  EventEditForm.Calenedar:=UniCalendarPanel1;
  EventEditForm.ClearEvent;
  EventEditForm.SetDate(ADate, ADate);
  EventEditForm.ShowModal;
end;

procedure TMainForm.UniCalendarPanel1EventClick(Sender: TUniCalendarPanel;
  AEventId: Integer; AEvent: TUniCalendarEvent);
begin
  EventEditForm.Calenedar:=UniCalendarPanel1;
  EventEditForm.SetEvent(AEvent);
  EventEditForm.ShowModal;
end;

procedure TMainForm.UniCalendarPanel1RangeSelect(Sender: TUniCalendarPanel;
  AStarDate, AEndDate: TDateTime);
begin
  EventEditForm.Calenedar:=UniCalendarPanel1;
  EventEditForm.ClearEvent;
  EventEditForm.SetDate(AStarDate, AEndDate);
  EventEditForm.ShowModal;
end;

 

procedure TMainForm.UniFormCreate(Sender: TObject);
var
  E : TUniCalendarEvent;
begin
  UniCalendar1.Date:=Date;
  UniCalendarPanel1.StartDate:=Date;

  E:=UniCalendarPanel1.Events.Add; //添加日程
  E.CalendarId:=1;                 //日程id
  E.Title:='Meeting';              //日程标题
  E.StartDate:=Date;               //开始时间
  E.EndDate:=Date+0.1;             //结束时间

  E:=UniCalendarPanel1.Events.Add;
  E.CalendarId:=2;
  E.Title:='Meeting-2';
  E.StartDate:=Date+1;
  E.EndDate:=Date+1.1;
  E.IsAllDay:=True;

  E:=UniCalendarPanel1.Events.Add;
  E.CalendarId:=3;
  E.Title:='Meeting-3';
  E.StartDate:=Date+1.1;
  E.EndDate:=Date+1.2;

  E:=UniCalendarPanel1.Events.Add;
  E.CalendarId:=1;
  E.Title:='Meeting-4';
  E.StartDate:=Date+2.1;
  E.EndDate:=Date+2.2;
  E.Reminder:='In 15 Minutes';
end;

在项目上用到了日历控件,主要用来显示签到签退记录。

 ... 
with UniMainModule.qryDetail do begin First; while not eof do begin
... if FieldByName('缺勤数').AsInteger = 0 then begin E := UniCalendarPanel1.Events.Add; E.Title := '出勤'; E.StartDate := nStart; E.EndDate := nStart; E.IsAllDay:=True; end; Inc(nid); next; end; First; end;

posted on 2013-08-28 22:54  `青石  阅读(1353)  评论(0编辑  收藏  举报