How to Draw a Custom Glyph within an Event
- 2 minutes to read
The scheduler provides a specially designed OnInitEventImages event that allows you to add custom images to user events.
Assume that an icon, which indicates that the scheduled user event is a meeting, is to be used. Then, to allow an end-user to turn a user event into a meeting, a custom editing control is to be added to the Event dialog (for instance, a check box). The corresponding custom field must be added to the storage (in the example below, it has been named Meeting) to store the check box value. To learn how to create custom fields and customize Event dialog, refer to the Customizing Event and Event recurrence dialogs help topic.
To load images to be used as custom icons into the scheduler, bind the TImageList (or TcxImageList) component to the scheduler using the scheduler’s EventImages property.
The following example shows how you can provide custom icons to events dependent upon event data.
// ...
procedure TForm1.cxScheduler1InitEventImages(Sender: TcxCustomScheduler; AEvent: TcxSchedulerControlEvent; AImages: TcxSchedulerEventImages);
var
AMeetingIcon: Integer;
AIsMeeting: Variant;
begin
// for a global scope the image index might be initialized at a higher application level
AMeetingIcon := 0;
AIsMeeting := AEvent.GetCustomFieldValueByName('Meeting');
if not VarIsNull(AIsMeeting) then
if AIsMeeting then AImages.Add(AMeetingIcon);
end;
The following image shows the code execution result: