'Declaration Public ReadOnly Property Phase As AppointmentDragPhase
public AppointmentDragPhase Phase {get;}
A return value of 'Beginning' indicates that this is the first firing of the event for the associated operation; a value of 'Moving' indicates that the operation is currently underway, and the user has moved the cursor to a different day or TimeSlot since the last time the event was fired. A return value of 'CopyStatusChanging' indicates that the user has pressed or released the Control key, changing the copy status of the drag operation.
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
using Infragistics.Win; using Infragistics.Win.UltraWinSchedule; using System.Diagnostics; this.monthViewSingle.AppointmentsDragging += new AppointmentsDraggingHandler(OnAppointmentsDragging); private void OnAppointmentsDragging(object sender, AppointmentsDraggingEventArgs e) { // Get a reference to the schedule control and the associated UltraCalendarInfo UltraScheduleControlBase control = sender as UltraScheduleControlBase; UltraCalendarInfo calendarInfo = 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 ( e.NewOwner != e.InitialOwner && e.NewOwner.IsUnassigned ) e.AllowOwnerChange = false; // 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 ) { TimeSpan span = e.NewDateTime.Date.Subtract( e.InitialDateTime.Date ); int delta = (int)Math.Abs(span.TotalDays); if ( delta > 7f ) { StringBuilder sb = 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 ); foreach( Appointment appointment in e.Appointments ) { sb.AppendLine( string.Format("{0} ({1})", appointment.Subject, appointment.StartDateTime.ToShortDateString()) ); } sb.AppendLine( Environment.NewLine ); sb.AppendLine( "Do you want to move the appointment(s)?" ); DialogResult result = MessageBox.Show( sb.ToString(), "AppointmentsDragging", MessageBoxButtons.YesNo ); 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