是否可以从 FMX TCalendar 组件禁用某些日期?
例如周末
如果能够强调他们是残疾人,例如残疾人,那就太好了。下图中的第 14 天和第 15 天
我可以通过在打开 HitTest 的情况下将矩形添加到列表框项目样式上来禁用它
这就是我对上图所做的
procedure TForm1.cal1DayClick(Sender: TObject);
var sTemp : String;
begin
cal1.StylesData['days.Selected.StyleLookup'] := 'ListBoxItemstyleCust';
end;
但我不知道如何在创建项目时访问样式列表框项目,即使这是我应该这样做的方式
最佳答案
经过一段时间的挖掘,这是对我发现的内容的快速解释 Source code here
在文件夹中 \Embarcadero\Studio\17.0\source\fmx 有一个FMX.Calendar.Style.pas文件
我已将该文件复制到与我的项目相同的位置,并将其重命名为 My.FMX.Calendar.Style.pas
我还将 TStyledCalendar 重命名为 TMyStyledCalendar,然后更改了初始化和终止
initialization
TPresentationProxyFactory.Current.Register(TCalendar, TControlType.Styled, TStyledPresentationProxy<TMyStyledCalendar>);
finalization
TPresentationProxyFactory.Current.Unregister(TCalendar, TControlType.Styled, TStyledPresentationProxy<TMyStyledCalendar>);
end.
initialization
TPresentationProxyFactory.Current.Unregister(TCalendar, TControlType.Styled, TStyledPresentationProxy<TStyledCalendar>);
TPresentationProxyFactory.Current.Register(TCalendar, TControlType.Styled, TStyledPresentationProxy<TMyStyledCalendar>);
finalization
TPresentationProxyFactory.Current.Unregister(TCalendar, TControlType.Styled, TStyledPresentationProxy<TMyStyledCalendar>);
还在使用部分添加了 FMX.Calendar.Style
在过程 FillDays 中;创建了一个新过程
procedure ChangeStyle(aDay : TDateTime;Item: TDayItem);
var wDay : Word;
begin
wDay := DayOfWeek(aDay-1);
if (wDay = DaySaturday) or (wday = DaySunday) then begin
item.Enabled := false;
if (Item.StyleLookup <> 'MyListBoxItemstyle') then
Item.StyleLookup := 'MyListBoxItemstyle';
end else begin
if (Item.StyleLookup <> '') then
Item.StyleLookup := '';
end;
end;
并添加了ChangeStyle( Item.Date, Item);到接下来的 FillDaysOfPreviousMonth;填充当前月份的天数;下个月的填充天数;
添加了一个样式来匹配 MyListBoxItemstyle
关于android - Delphi FMX TCalendar - 禁用周末,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33770484/