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

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   get   


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                 //本地語言識別碼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;

:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.