Fired before one or more selected
Appointment and/or
Note objects are deleted
The event handler receives an argument of type BeforeActivitiesDeletedEventArgs containing data related to this event. The following BeforeActivitiesDeletedEventArgs properties provide information specific to this event.
This example demonstrates how to use the BeforeActivitiesDeletedEventArgs class' properties to only display a dialog when appointments are deleted.
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.
Private Sub UltraMonthViewSingle1_BeforeActivitiesDeleted(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinSchedule.BeforeActivitiesDeletedEventArgs) Handles ultraMonthViewSingle.BeforeActivitiesDeleted
'----------------------------------------------------------------------------------------------------
' Description
' BeforeActivitiesDeleted
'
' Fires before one or more Appointments or Notes are deleted via the control's UI.
' If the event is canceled, the activities are not deleted, and the AfterActivitiesDeleted event does not fire.
'
'----------------------------------------------------------------------------------------------------
' Set the DisplayPromptMsg property to false so that the control's
' default dialog is not displayed
e.DisplayPromptMsg = False
' Since the control will remove all selected appointments and/or notes, get
' the number of selected appointments
Dim selectedAppointmentCount As Integer = Me.ultraMonthViewSingle1.CalendarInfo.SelectedAppointments.Count
' If there were no selected Appointments, then the user is only deleting
' Notes, so we need not display a confirmation dialog. The 'Cancel' property
' of the event arguments defaults to false, so we can return now and the Notes
' will be deleted without a prompt.
If selectedAppointmentCount = 0 Then Return
' Build the dialog string
Dim info As String = String.Empty
info += selectedAppointmentCount.ToString() + " Appointment(s) will be deleted." + vbCrLf
info += "Choose Yes to delete the Appointments, or No to exit without deleting them."
' Display the custom dialog
Dim result As DialogResult = MessageBox.Show(info, "Delete selected Appointments", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
' If the user selected No, set the 'Cancel' property of the event arguments to true
If result = DialogResult.No Then e.Cancel = True
End Sub
private void ultraMonthViewSingle1_BeforeActivitiesDeleted(object sender, Infragistics.Win.UltraWinSchedule.BeforeActivitiesDeletedEventArgs e)
{
//----------------------------------------------------------------------------------------------------
// Description
// BeforeActivitiesDeleted
//
// Fires before one or more Appointments or Notes are deleted via the control's UI.
// If the event is canceled, the activities are not deleted, and the AfterActivitiesDeleted event does not fire.
//
//----------------------------------------------------------------------------------------------------
// Set the DisplayPromptMsg property to false so that the control's
// default dialog is not displayed
e.DisplayPromptMsg = false;
// Since the control will remove all selected appointments and/or notes, get
// the number of selected appointments
int selectedAppointmentCount = this.ultraMonthViewSingle1.CalendarInfo.SelectedAppointments.Count;
// If there were no selected Appointments, then the user is only deleting
// Notes, so we need not display a confirmation dialog. The 'Cancel' property
// of the event arguments defaults to false, so we can return now and the Notes
// will be deleted without a prompt.
if ( selectedAppointmentCount == 0 )
return;
// Build the dialog string
string info = string.Empty;
info += selectedAppointmentCount.ToString() + " Appointment(s) will be deleted." + "\n";
info += "Choose Yes to delete the Appointments, or No to exit without deleting them.";
// Display the custom dialog
DialogResult result = MessageBox.Show( info, "Delete selected Appointments", MessageBoxButtons.YesNo, MessageBoxIcon.Warning );
// If the user selected No, set the 'Cancel' property of the event arguments to true
if ( result == DialogResult.No )
e.Cancel = true;
}
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