'Declaration Public Event AppointmentsDragging As AppointmentsDraggingHandler
public event AppointmentsDraggingHandler AppointmentsDragging
The event handler receives an argument of type AppointmentsDraggingEventArgs containing data related to this event. The following AppointmentsDraggingEventArgs properties provide information specific to this event.
Property | Description |
---|---|
AllowCopy | Returns or sets whether copies of the appointment(s) can be made during the drag operation. |
AllowOwnerChange | Returns or sets whether the appointment(s) can be dragged to a different Owner than the one for which the drag operation was initiated. |
Appointments | Returns a read-only collection of the appointments that are being dragged. |
Cancel (Inherited from System.ComponentModel.CancelEventArgs) | |
CopyCursor | Returns or sets the cursor which is displayed during the drag operation when the dragged items are being copied. |
HasCopies | Returns a boolean indicating whether the drag operation currently contains copied Appointment. |
InitialDateTime (Inherited from Infragistics.Win.UltraWinSchedule.CancelableAppointmentDragEventArgs) | Returns the DateTime over which the cursor was positioned when the operation was initiated. |
InitialOwner | Returns the Owner of the appointment(s) at the time the drag operation was initiated. |
MoveCursor | Returns or sets the cursor which is displayed during the drag operation when the items are being moved without being copied. |
NewDateTime (Inherited from Infragistics.Win.UltraWinSchedule.CancelableAppointmentDragEventArgs) | Returns the DateTime closest to the current cursor position. |
NewOwner | Returns the new Owner of the appointment(s), based on the current cursor position. |
Phase | Returns the phase of the drag operation that this event firing represents, i.e., whether it is beginning, in progress, or ending. |
The AppointmentsDragging event notifies a listener during all phases of an appointment drag operation. The Phase property identifies whether the drag operation has just been initiated, is continuing because the end user is moving the mouse while the logical left button is pressed, or is about to be committed because the end user released the mouse. The event can be canceled during any phase, in which case the dragged appointment(s) are returned to their pre-drag state. A listener can use this event for the following purposes:
If this event is not canceled, the AppointmentsDragDrop event is fired at the end of the drag operation.
Appointments can be dragged to another control by canceling the AppointmentsDragging event, and calling the DoDragDrop method on the schedule control from which the appointments are being dragged. Note that the drop target control must in this case have its AllowDrop property set to true, and the developer must also handle its DragDrop event in order to process the data.
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