Version

Appointment Property (AppointmentResizingEventArgs)

Returns the Appointment on which the resize operation is being performed.
Syntax
'Declaration
 
Public ReadOnly Property Appointment As Appointment
public Appointment Appointment {get;}
Example
The following code sample demonstrates how to use the AppointmentsResizing event to conditionally prevent appointments from being resized:

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 System.Collections.Generic
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinSchedule
Imports System.Diagnostics


    AddHandler Me.dayView.AppointmentResizing, AddressOf OnAppointmentsResizing

    Private Sub OnAppointmentsResizing(ByVal sender As Object, ByVal e As AppointmentResizingEventArgs)
        Dim control As UltraDayView = sender
        If Not control Is Nothing Then

            '  Get the delta between the original drag point and the new one
            Dim span As TimeSpan = e.InitialDateTime.Subtract(e.NewDateTime)
            Dim delta As Int32 = Math.Abs(span.TotalMinutes)

            '  Access the change history from the Tag property
            Dim changeHistory As List(Of AppointmentChangeHistoryItem) = Nothing
            If e.Appointment.Tag Is Nothing Then e.Appointment.Tag = New List(Of AppointmentChangeHistoryItem)

            changeHistory = e.Appointment.Tag

            '  If the appointment's duration is being increased by more than one hour,
            '  add an entry to the change history
            If (e.Phase = AppointmentResizePhase.Ending AndAlso delta > 60) Then
                changeHistory.Add(New AppointmentChangeHistoryItem(DateTime.Now, e))
            End If

            '  If the duration has been changed more than a certain number
            '  of times, cancel the event
            If e.Phase = AppointmentResizePhase.Beginning AndAlso changeHistory.Count > 5 Then
                e.Cancel = True
                MessageBox.Show("Access denied", "AppointmentsResizing", MessageBoxButtons.OK)
            End If

            '  Clear the selection when a new resize operation begins
            e.SelectionAction = AppointmentResizeSelectionAction.SelectOnlyThisAppointment
        End If

    End Sub

    Public Structure AppointmentChangeHistoryItem

        Public timeStamp As DateTime
        Public data As AppointmentResizingEventArgs
        Public Sub New(ByVal timeStamp As DateTime, ByVal data As AppointmentResizingEventArgs)

            Me.timeStamp = timeStamp
            Me.data = data
        End Sub

    End Structure
using System.Collections.Generic;
using Infragistics.Win;
using Infragistics.Win.UltraWinSchedule;
using System.Diagnostics;


    this.dayView.AppointmentResizing += new AppointmentResizingHandler(OnAppointmentsResizing);            

    private void OnAppointmentsResizing(object sender, AppointmentResizingEventArgs e)
    {
        UltraDayView control = sender as UltraDayView;
        if ( control != null )
        {
            //  Get the delta between the original drag point and the new one
            TimeSpan span = e.InitialDateTime.Subtract( e.NewDateTime );
            int delta = (int)Math.Abs( span.TotalMinutes );

            //  Access the change history from the Tag property
            List<AppointmentChangeHistoryItem> changeHistory = null;
            if ( e.Appointment.Tag == null )
                e.Appointment.Tag = new List<AppointmentChangeHistoryItem>();

            changeHistory = e.Appointment.Tag as List<AppointmentChangeHistoryItem>;
            
            //  If the appointment's duration is being increased by more than one hour,
            //  add an entry to the change history
            if ( e.Phase == AppointmentResizePhase.Ending && delta > 60 )
                changeHistory.Add( new AppointmentChangeHistoryItem(DateTime.Now, e) );

            //  If the duration has been changed more than a certain number
            //  of times, cancel the event
            if ( e.Phase == AppointmentResizePhase.Beginning && changeHistory.Count > 5 )
            {
                e.Cancel = true;
                MessageBox.Show( "Access denied", "AppointmentsResizing", MessageBoxButtons.OK );
            }

            //  Clear the selection when a new resize operation begins
            e.SelectionAction = AppointmentResizeSelectionAction.SelectOnlyThisAppointment;
        }
    }

    public struct AppointmentChangeHistoryItem
    {
        public DateTime timeStamp;
        public AppointmentResizingEventArgs data;
        public AppointmentChangeHistoryItem( DateTime timeStamp, AppointmentResizingEventArgs data )
        {
            this.timeStamp = timeStamp;
            this.data = data;
        }
    }
Requirements

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

See Also