Imports Infragistics.Win
Imports Infragistics.Win.UltraWinSchedule
Imports System.Diagnostics
AddHandler Me.monthViewSingle.AppointmentsDragging, AddressOf OnAppointmentsDragging
Private Sub OnAppointmentsDragging(ByVal sender As Object, ByVal e As AppointmentsDraggingEventArgs)
' Get a reference to the schedule control and the associated UltraCalendarInfo
Dim control As UltraScheduleControlBase = sender
Dim calendarInfo As UltraCalendarInfo = control.CalendarInfo
' Disallow copying of appointments this prevents copies of the
' dragged appointments from being made when the user presses the
' Control key.
e.AllowCopy = False
' Disallow dragging the appointments to the unassigned owner,
' if they originally belonged to a different owner.
If (Not (e.NewOwner Is e.InitialOwner) AndAlso e.NewOwner.IsUnassigned) Then
e.AllowOwnerChange = False
End If
' If the delta between the initial date and the new date is more
' than seven days, prompt the user to make sure they want to continue.
'
' To avoid stealing capture (and thus terminating the drag operation),
' we can only do this during the final phase of the drag operation,
' so check e.Phase to make sure that is the case.
If e.Phase = AppointmentDragPhase.Ending Then
Dim span As TimeSpan = e.NewDateTime.Date.Subtract(e.InitialDateTime.Date)
Dim delta As Int32 = Math.Abs(span.TotalDays)
If (delta > 7.0F) Then
Dim sb As StringBuilder = New StringBuilder()
sb.AppendLine("The following appointment(s) are being dragged by more than seven days from their initial start time(s):")
sb.AppendLine(Environment.NewLine)
Dim appointment As Appointment
For Each appointment In e.Appointments
sb.AppendLine(String.Format("{0} ({1})", appointment.Subject, appointment.StartDateTime.ToShortDateString()))
Next
sb.AppendLine(Environment.NewLine)
sb.AppendLine("Do you want to move the appointment(s)?")
Dim result As DialogResult = MessageBox.Show(sb.ToString(), "AppointmentsDragging", MessageBoxButtons.YesNo)
If (result = System.Windows.Forms.DialogResult.No) Then e.Cancel = True
End If
End If
End Sub