Version

DateNavigationButtonClicked Event

Fired when a DateNavigationButtonUIElement is clicked, giving listeners the opportunity to change the action that is taken.
Syntax
'Declaration
 
Public Event DateNavigationButtonClicked As DateNavigationButtonClickedHandler
public event DateNavigationButtonClickedHandler DateNavigationButtonClicked
Event Data

The event handler receives an argument of type DateNavigationButtonClickedEventArgs containing data related to this event. The following DateNavigationButtonClickedEventArgs properties provide information specific to this event.

PropertyDescription
ButtonAction Returns or sets a value which determines the navigational action that will be taken when execution returns from the event.
DateTimeInterval Returns the DateTimeInterval instance associated with the column header whose date navigation button was clicked.
DateTimeRange Returns a DateTimeRange instance which describes the date/time range spanned by the column header whose date navigation button was clicked.
NavigationDirection Returns a value which determines the direction of navigation, i.e., whether the user is navigating forward or backward.
Example
The following code sample demonstrates how to use the DateNavigationButtonClicked event to customize date navigation:

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.ultraTimeLineView1.DateNavigationButtonClicked, AddressOf Me.OnDateNavigationButtonClicked

    Private Sub OnDateNavigationButtonClicked(ByVal sender As Object, ByVal e As DateNavigationButtonClickedEventArgs)

        Dim control As UltraTimelineView = sender
        Dim timeInterval As TimeInterval = e.DateTimeInterval
        If Not timeInterval Is Nothing AndAlso _
            timeInterval.DateNavigationButtonActionResolved = TimelineViewDateNavigationButtonAction.None Then

            Dim tzi As TimeZoneInfo = timeInterval.TimeZone
            If Not tzi Is Nothing AndAlso Not TimeZoneInfo.CurrentTimeZone Is Nothing Then

                '  Get the StartDateTime from the DateRange, which will
                '  contain the local time for that TimeZone.
                Dim nextDate As DateTime = e.DateTimeRange.StartDateTime

                '  Convert the local time for that TimeZone into local time
                '  for the current time zone
                nextDate = New DateTime(nextDate.Ticks, DateTimeKind.Local)
                Dim utc As DateTime = nextDate.Add(tzi.UtcOffset)
                If (tzi.IsDaylightSavingTime(utc)) Then
                    utc = utc.Add(tzi.DaylightUtcOffset)

                    nextDate = TimeZoneInfo.CurrentTimeZone.ToLocalTime(utc, DateTimeKind.Utc)

                    '  Get the next/previous date depending on the navigation direction.
                    Dim forward As Boolean = IIf(e.NavigationDirection = DateNavigationDirection.Forward, True, False)
                    nextDate = timeInterval.GetNextDate(nextDate, forward)

                    '  Call EnsureDateTimeVisible to navigate to the date
                    control.EnsureDateTimeVisible(nextDate, forward = False)
                End If
            End If
        End If

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

    this.ultraTimeLineView1.DateNavigationButtonClicked += new DateNavigationButtonClickedHandler(this.OnDateNavigationButtonClicked);

    private void OnDateNavigationButtonClicked(object sender, DateNavigationButtonClickedEventArgs e)
    {
        UltraTimelineView control = sender as UltraTimelineView;
        TimeInterval timeInterval = e.DateTimeInterval as TimeInterval;
        if ( timeInterval != null &&
             timeInterval.DateNavigationButtonActionResolved == TimelineViewDateNavigationButtonAction.None )
        {
            TimeZoneInfo tzi = timeInterval.TimeZone;
            if ( tzi != null && TimeZoneInfo.CurrentTimeZone != null )
            {
                //  Get the StartDateTime from the DateRange, which will
                //  contain the local time for that TimeZone.
                DateTime next = e.DateTimeRange.StartDateTime;

                //  Convert the local time for that TimeZone into local time
                //  for the current time zone
                next = new DateTime( next.Ticks, DateTimeKind.Local );
                DateTime utc = next.Add( tzi.UtcOffset );
                if ( tzi.IsDaylightSavingTime(utc) )
                    utc = utc.Add( tzi.DaylightUtcOffset );

                next = TimeZoneInfo.CurrentTimeZone.ToLocalTime( utc, DateTimeKind.Utc );
                
                //  Get the next/previous date depending on the navigation direction.
                bool forward = e.NavigationDirection == DateNavigationDirection.Forward;
                next = timeInterval.GetNextDate( next, forward );

                //  Call EnsureDateTimeVisible to navigate to the date
                control.EnsureDateTimeVisible( next, forward == false );
            }

        }
    }
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