This example demonstrates how to use the parameters of the 'BeforeDisplayAppointmentDialog' event to cancel the display of the appointment dialog or control what recurrence information the user will edit (if the appointment is associated with a recurrence).
For an overview of how to handle events in Visual Basic or Visual C#, see
Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see
Consuming Events in the
.NET Framework Developer's Guide.
Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinSchedule
Imports System.Diagnostics
Private Sub ultraCalendarInfo1_BeforeDisplayAppointmentDialog(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinSchedule.DisplayAppointmentDialogEventArgs) Handles ultraCalendarInfo1.BeforeDisplayAppointmentDialog
'----------------------------------------------------------------------------------------------------
' Description
' BeforeDisplayAppointmentDialog
'
' Fires before the Appointment dialog is displayed
' If canceled, the Appointment dialog is not displayed, and the AfterDisplayAppointmentDialog event does not fire.
'
'----------------------------------------------------------------------------------------------------
If Not e.IsExistingAppointment Then
If e.Appointment.StartDateTime < DateTime.Today Then
' To prevent the displaying of the AppointmentDialog, set the Cancel
' property to true
e.Cancel = True
' Let the end user know what happened
Dim info As String = String.Empty
info += "Sorry, but you cannot add new appointments in the past."
MessageBox.Show(info, "BeforeDisplayAppointmentDialog", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
Else
' this must be an existing appointment for which the dialog
' will be displayed...
' if this is a recurring appointment instance...
If Not e.Appointment.RecurringAppointmentRoot Is Nothing Then
' Outlook prompts the user as to whether the series
' or the occurrence should be edited. In UltraCalendarInfo,
' this can be controlled by setting the 'RecurrenceEditType'
' of the event arguments.
'
' if the appointment is already a variance (a modified occurrence)
' then let them edit the occurrence information
If e.Appointment.IsVariance Then
e.RecurrenceEditType = RecurrenceEditType.Occurrence
Else 'otherwise, let them edit the series so they don't create variances Then
e.RecurrenceEditType = RecurrenceEditType.Series
End If
End If
End If
End Sub
using System.Diagnostics;
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinSchedule;
private void ultraCalendarInfo1_BeforeDisplayAppointmentDialog(object sender, Infragistics.Win.UltraWinSchedule.DisplayAppointmentDialogEventArgs e)
{
//----------------------------------------------------------------------------------------------------
// Description
// BeforeDisplayAppointmentDialog
//
// Fires before the Appointment dialog is displayed
// If canceled, the Appointment dialog is not displayed, and the AfterDisplayAppointmentDialog event does not fire.
//
//----------------------------------------------------------------------------------------------------
if ( ! e.IsExistingAppointment )
{
if (e.Appointment.StartDateTime < DateTime.Today)
{
// To prevent the displaying of the AppointmentDialog, set the Cancel
// property to true
e.Cancel = true;
// Let the end user know what happened
string info = string.Empty;
info += "Sorry, but you cannot add new appointments in the past.";
MessageBox.Show( info, "BeforeDisplayAppointmentDialog", MessageBoxButtons.OK, MessageBoxIcon.Error );
}
}
else
{
// this must be an existing appointment for which the dialog
// will be displayed...
// if this is a recurring appointment instance...
if (e.Appointment.RecurringAppointmentRoot != null)
{
// Outlook prompts the user as to whether the series
// or the occurrence should be edited. In UltraCalendarInfo,
// this can be controlled by setting the 'RecurrenceEditType'
// of the event arguments.
//
// if the appointment is already a variance (a modified occurrence)
// then let them edit the occurrence information
if (e.Appointment.IsVariance)
e.RecurrenceEditType = RecurrenceEditType.Occurrence;
else //otherwise, let them edit the series so they don't create variances
e.RecurrenceEditType = RecurrenceEditType.Series;
}
}
}
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2