How to: Display Custom Tooltips for Appointments
- 2 minutes to read
Important
To display tooltips, hide appointment flyouts using the SchedulerOptionsCustomization.AllowDisplayAppointmentFlyout property:
By default the appointment tooltip contains the text obtained from the Appointment.Subject property. Appointments with empty subjects do not display a tooltip at all.
To display a tooltip for an appointment with empty subject, handle the SchedulerControl.AppointmentViewInfoCustomizing event and assign the tooltip text to the e.ViewInfo.ToolTipText property.
private void SchedulerControl1_AppointmentViewInfoCustomizing(object sender, AppointmentViewInfoCustomizingEventArgs e) {
if (e.ViewInfo.DisplayText == String.Empty)
e.ViewInfo.ToolTipText = String.Format("Started at {0:g}", e.ViewInfo.Appointment.Start);
}
The following example demonstrates how to control the tooltip appearance and a tooltip message which is displayed for each appointment.
Drop a ToolTipController component from Toolbox onto a form, assign it to the SchedulerControl.ToolTipController property, and adjust tooltip controller settings as your need dictates. You can also handle the ToolTipController.BeforeShow event to specify tooltip text and appearance.
The code below demonstrates the ToolTipController.BeforeShow event handler.
Font font14 = new Font("Times New Roman", 14);
Font font8 = new Font("Comic Sans MS", 8);
private void toolTipController1_BeforeShow(object sender, ToolTipControllerShowEventArgs e) {
ToolTipController controller = sender as ToolTipController;
AppointmentViewInfo aptViewInfo = controller.ActiveObject as AppointmentViewInfo;
if (aptViewInfo == null) return;
if (toolTipController1.ToolTipType == ToolTipType.Standard) {
e.IconType = ToolTipIconType.Information;
e.ToolTip = aptViewInfo.Description;
}
if (toolTipController1.ToolTipType == ToolTipType.SuperTip) {
SuperToolTip SuperTip = new SuperToolTip();
SuperToolTipSetupArgs args = new SuperToolTipSetupArgs();
args.Title.Text = "Info";
args.Title.Font = font14;
args.Contents.Text = aptViewInfo.Description;
args.Contents.Image = resImage;
args.ShowFooterSeparator = true;
args.Footer.Font = font8;
args.Footer.Text = "SuperTip";
SuperTip.Setup(args);
e.SuperTip = SuperTip;
}
}