2

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

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

Fabrizio
  • 7,603
  • 6
  • 44
  • 104
user763539
  • 3,509
  • 6
  • 44
  • 103

1 Answers1

4

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;

enter image description here

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

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;
Fabrizio
  • 7,603
  • 6
  • 44
  • 104
Jens Borrisholt
  • 6,174
  • 1
  • 33
  • 67
  • any way to show a footer with 'Today dd/mm/yyyy' that would take me (on click) to today's date ? – user763539 Apr 08 '15 at 00:18
  • Yu can add a cxlabel in which you display your text. If you want an other dateFormat try using FormatDateTime(FormatSettings.ShortDateFormat, dt). As for your jump, when you assign a Data to you DateNavigator it will jump to the given dage e.g cxDateNavigator1.Date := Today; wil jump to todays date. If you want me to make an example for you, please create a new question – Jens Borrisholt Apr 08 '15 at 05:41