How to show custom Tooltip for Schedule Appointments
Categories: DotNetBar for Windows Forms, How To
If you need to show custom tooltip for Appointments in WinForms (Windows Forms) CalendarView control you can do so by handling CalendarView.MouseEnter event to show tooltip and CalendarView.MouseLeave to hide tooltip. Following code illustrates how to show custom Balloon style tooltip:
C#:
private Balloon _AppointmentBalloon = null; private void SetupAppointmentBalloon() { _AppointmentBalloon = new Balloon(); _AppointmentBalloon.AutoCloseTimeOut = 10; _AppointmentBalloon.Owner = this; } private void calendarView1_MouseEnter(object sender, EventArgs e) { AppointmentView view = sender as AppointmentView; if (view == null) return; if (_AppointmentBalloon == null) SetupAppointmentBalloon(); _AppointmentBalloon.CaptionText = "Balloon for Appointment"; _AppointmentBalloon.Text = "This is custom balloon for my appointment: " + view.Appointment.Subject; _AppointmentBalloon.AutoResize(); _AppointmentBalloon.Show(view, false); } private void calendarView1_MouseLeave(object sender, EventArgs e) { if (_AppointmentBalloon != null && _AppointmentBalloon.Visible) _AppointmentBalloon.Hide(); }
VB:
Private _AppointmentBalloon As Balloon = Nothing Private Sub SetupAppointmentBalloon() _AppointmentBalloon = New Balloon() _AppointmentBalloon.AutoCloseTimeOut = 10 _AppointmentBalloon.Owner = Me End Sub Private Sub calendarView1_MouseEnter(ByVal sender As Object, ByVal e As EventArgs) Dim view As AppointmentView = TryCast(sender, AppointmentView) If view Is Nothing Then Return End If If _AppointmentBalloon Is Nothing Then SetupAppointmentBalloon() End If _AppointmentBalloon.CaptionText = "Balloon for Appointment" _AppointmentBalloon.Text = "This is custom balloon for my appointment: " & view.Appointment.Subject _AppointmentBalloon.AutoResize() _AppointmentBalloon.Show(view, False) End Sub Private Sub calendarView1_MouseLeave(ByVal sender As Object, ByVal e As EventArgs) If _AppointmentBalloon IsNot Nothing AndAlso _AppointmentBalloon.Visible Then _AppointmentBalloon.Hide() End If End Sub
Related posts:
Leave a Reply!