cxDateNavigator1将周末文本设置为红色 [英] cxDateNavigator1 set weekend days text color in red

查看:170
本文介绍了cxDateNavigator1将周末文本设置为红色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TcxDateNavigator 中,是否可以用不同的文本颜色(红色)标记周末(星期六,星期日)?

In TcxDateNavigator, is it possible to mark the weekend (Saturday, Sunday) with a diffrent text color (red)?

TMS已实现此功能,但在这个DevExpress组件中似乎找不到。

TMS has this feature implemented but I can't seem to find that in this DevExpress component.

推荐答案

对于 cxDateNavigator ,您可以使用其 OnCustomDrawDayNumber 事件处理程序。 ,如下所示:

As for the cxDateNavigator, you can use its OnCustomDrawDayNumber event handler, for instance, as follows:

uses
  DateUtils, cxDateUtils;

procedure TForm60.cxDateNavigator1CustomDrawDayNumber(Sender: TObject; ACanvas: TcxCanvas; AViewInfo: TcxSchedulerDateNavigatorDayNumberViewInfo; var ADone: Boolean);
begin
  if DayOfTheWeek(AViewInfo.Date) in [DaySaturday, DaySunday] then
  begin
    AViewInfo.Bold := True;
    ACanvas.Font.Color := clGreen;
    ACanvas.Brush.Color := clYellow;
  end;
end;

我不建议您在周末使用红色,因为它通常表示假期。

I would not recommend you to use red for weekends, because it usally indicates a holiday.

如果您想知道鼠标指向的日期。您可以实现 OnMouseMove 事件:

And if you want to know which date you are pointing at with you mouse. You can implement a OnMouseMoveevent:

procedure TForm60.cxDateNavigator1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
  dt: TDateTime;
begin
  dt := TcxDateNavigator(Sender).HitTest.Time;
  if dt = NullDate then
    Caption := 'You are pointing outside the calendar area'
  else
    Caption := 'You are pointing at ' + FormatDateTime(FormatSettings.LongDateFormat, dt);

end;

这篇关于cxDateNavigator1将周末文本设置为红色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆