ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

使用 IntraWeb (22) - 基本控件之 TIWCalendar

2021-04-29 23:56:33  阅读:170  来源: 互联网

标签:IWCalendar1 控件 IntraWeb 22 TIWForm1 ACell Integer property procedure


   使用 IntraWeb (22) - 基本控件之 TIWCalendar    


TIWCalendar: 日历控件, 继承于 TIWCustomGrid, 所以它和 TIWGrid 共同属性特多.

它的 Cell 是 TIWCalendarCell 对象, 直接从 TIWGridCell 继承.



TIWCalendar 所在单元及继承链:
IWCompCalendar.TIWCalendar < TIWCustomGrid < TIWCustomControl < TIWBaseHTMLControl < TIWBaseControl < TIWVCLBaseControl < TControl < TComponent < TPersistent < TObject

主要成员:


property Cell[const ARow: Integer, const AColumn: Integer]: TIWCalendarCell //
property CurrentDayImage: TIWFileReference    //显示在当前日期的图片
property CaptionToday: string                 //当前日期的附加标题
property PreviousMonthImage: TIWFileReference //"后退"图片
property NextMonthImage: TIWFileReference     //"前进"图片
property CaptionPrevious: string          //"后退"标题
property CaptionNext: string              //"前进"标题
property CalendarHeaderColor: TIWColor    //标题背景色
property CalendarColor: TIWColor          //背景色
property AlternateCalendarColor: TIWColor //用于交替的背景色
property CheckerBoard: Boolean            //是否使用交替背景
property CalendarHeaderFont: TIWFont  //标题字体
property CalendarFont: TIWFont        //字体
property StartDate: TDateTime         //默认当前日期
property SelectedDate: TDateTime      //就是刚刚点过的日期
property DisplayYear: Boolean         //是否显示"年"
property LocaleID: Integer                 //本地语言 ID

property CellRenderOptions: TIWCellRenderOptions //
property BorderColors: TIWGridBorderColors //
property BGColor: TIWColor                 //
property BorderSize: Integer               //
property BorderStyle: TIWGridBorderStyle   //
property Caption: TCaption     //
property CellPadding: Integer  //          
property CellSpacing: Integer  //
property Font: TIWFont         //
property Lines: TIWGridLines   //
property Summary: string       //
property UseFrame: Boolean     //
property UseSize: Boolean      //
property HiddenColumns: TStringList //

property OnDateChange: TIWCalendarDateChange     //
property OnGetDateInformation: TIWCalendarGetDateInformation  //
property OnGetDayNames: TIWCalendarGetDayNames   //
property OnGetMonthName: TIWCalendarGetMonthName //
property OnRenderCell: TIWOnRenderCell           //
property OnRender: TNotifyEvent                  //
property OnGetCellRenderOptions: TIWGetCellRenderOptionsEvent //

procedure SetHeaderCells;                                          //
function IsRowVisible(ARow: Integer): Boolean                      //
procedure SetColumnVisibility(AColumn: Integer; AVisible: Boolean) //


TIWCalendarCell:



{IWCompCalendar.TIWCalendarCell < TIWGridCell < TCollectionItem < TPersistent < TObject}

property CellDate: TDateTime          //
property DateInformation: TStringList //与日期关联的备注信息
property ImageFile: TIWImageFile      //看来每个 Cell 都可以使用图像; 这应该是为当前日期准备的

{还包括和 TIWGridCell 相同的一些}


改控件拖到窗体上就能用, 如果要写一行代码的话应该是: IWCalendar1.StartDate := Date;

下面是个比较全面的测试:


var
  gInfoList: TStrings; //用于记录自定义的备忘信息

procedure TIWForm1.IWAppFormCreate(Sender: TObject);
begin
  gInfoList := TStringList.Create; //如果是长期保存, 它应该是从服务器上读取某个文件

  IWCalendar1.Caption := '';           //标题无用
  IWCalendar1.CaptionPrevious := '<<'; //其实给它图像(PreviousMonthImage)更好看
  IWCalendar1.CaptionNext := '>>';

  IWCalendar1.CalendarHeaderColor := $88aaaa;

  IWCalendar1.CalendarColor := $eeffff;
  IWCalendar1.AlternateCalendarColor := $ccdddd; //交替颜色
  IWCalendar1.CheckerBoard := True;              //确认使用指定的 "交替颜色" 与背景色交替使用

  IWCalendar1.CalendarFont.Size := 12;
  LinkColor := $0033dd; //Cell 中的文本其实成了链接了, 如果要改变 Cell 中文本的显示, 最好使用 Css

  IWCalendar1.CaptionToday := '★'; //突出标示当前日期, 或使用图像(CurrentDayImage)

  IWCalendar1.StartDate := Date; //显然使用 Date 比 Now 更合理; 这句还能起到刷新的作用
end;

{通过 OnGetDayNames 事件调整周标题显示}
procedure TIWForm1.IWCalendar1GetDayNames(var Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday: string);
begin
  Sunday := '周末';
end;

{通过 OnGetMonthName 事件调整月份显示}
procedure TIWForm1.IWCalendar1GetMonthName(MonthNumber: Integer; var MonthName: string);
begin
  MonthName := MonthNumber.ToString + '月';
end;

{通过 OnRenderCell 事件调整更多显示细节}
procedure TIWForm1.IWCalendar1RenderCell(ACell: TIWGridCell; const ARow, AColumn: Integer);
begin
  {让当前选定的日期在字号上有所区别}
  if TIWCalendarCell(ACell).CellDate = TIWCalendar(ACell.Grid).SelectedDate then
    ACell.Font.Size := 14
  else
    ACell.Font.Size := ACell.Grid.Font.Size;

  {ARow = 0 是最上面一行, 也就是带月导航的那行}
  if ARow = 0 then ACell.Font.Size := 13;
  {Arow = 1 是周标题}
  if ARow = 1 then ACell.Height := '20'; //Height 是 字符串在 Html 中不难理解
end;

{添加和日期关联的备注信息}
procedure TIWForm1.IWButton1AsyncClick(Sender: TObject; EventParams: TStringList);
begin
  gInfoList.Values[FormatDateTime('ddmmyyyy', IWCalendar1.SelectedDate)] := IWMemo1.Text;
end;

{选择不同日期时再取回备注信息}
procedure TIWForm1.IWCalendar1DateChange(ADate: TDateTime);
begin
  IWMemo1.Text := gInfoList.Values[FormatDateTime('ddmmyyyy', ADate)];
end;

{通过切换月份, 可以看到刚添加的与日期关联的备注信息}
procedure TIWForm1.IWCalendar1GetDateInformation(ADate: TDateTime; VInformation: TStrings);
begin
  VInformation.Text := gInfoList.Values[FormatDateTime('ddmmyyyy', ADate)];
end;

procedure TIWForm1.IWAppFormDestroy(Sender: TObject);
begin
  gInfoList.Free;
end;


效果图:
watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=



标签:IWCalendar1,控件,IntraWeb,22,TIWForm1,ACell,Integer,property,procedure
来源: https://blog.51cto.com/u_14617575/2744239

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有