Ticket A2656
Visible to All Users

How to display a count of the events for a particular day within the month view

created 20 years ago

Description:
I'd like to provide my users with an "Event Count" indicator for each day in the weeks view of the scheduler. I'd like it to appear to the left of each day, left aligned and with a blue background.

Answer:
To implement this task you should handle the Scheduler’s OnCustomDrawContent event within this event you should do the following:

  1. Apply the default drawing to the content cell. This can be done by calling the Draw method of the AViewInfo parameter.
  2. Calculate the number of events for the current day. This can be done by calling the GetEvents method of the SchedulerStorage:
Delphi
var AList: TcxSchedulerFilteredEventList; ACount, I: Integer; ... AList := TcxSchedulerFilteredEventList.Create; try cxSchedulerStorage1.GetEvents(AList, AViewInfo.TimeStart, AViewInfo.TimeFinish); ACount := 0; for I := 0 to AList.Count - 1 do if AList[I].IsDayEvent(AViewInfo.TimeStart) then Inc(ACount); finally AList.Free; end;
  1. Draw the results on the content canvas:
Delphi
ACanvas.Brush.Style := bsClear; if TcxSchedulerMonthDayContentCellViewInfo(AViewInfo).Selected then ACanvas.Font.Color := TcxSchedulerMonthDayContentCellViewInfo(AViewInfo).SelectionTextColor else ACanvas.Font.Color := AViewInfo.TextColor; with TcxSchedulerMonthDayContentCellViewInfoAccess(AViewInfo) do ACanvas.DrawTexT('(' + IntToStr(ACount) + ')', Rect(Bounds.Left + 2, FTextRect.Top, FTextRect.Left, FTextRect.Bottom), cxAlignLeft or cxAlignVCenter); ACanvas.Brush.Style := bsSolid;

And finally set the ADone parameter to True.
The attached project demonstrates how to accomplish this task.
See Also:
How to obtain the number of events scheduled for a given date

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.