'Declaration Public ReadOnly Property DateRecurrence As DateRecurrence
public DateRecurrence DateRecurrence {get;}
When this dialog was created with an AppointmentRecurrence instance, this property returns a downcasted reference, i.e., only properties exposed by the base DateRecurrence class are available. Use the AppointmentRecurrence property when this dialog is used to edit an appointment recurrence.
Imports System.Collections.Generic Imports Infragistics.Win Imports Infragistics.Win.UltraWinSchedule Imports System.Diagnostics Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Create a new DateRecurrence on which the dialog session will be based. Dim recurrence As DateRecurrence = New DateRecurrence(New DateTime(DateTime.Today.Year, 1, 1)) recurrence.RangeEndDate = New DateTime(DateTime.Today.Year, 12, 31) ' Create and show the RecurrenceDialog in DateRecurrence mode Dim dialog As New RecurrenceDialog(recurrence) dialog.ShowDialog() ' If the dialog session was not canceled... If dialog.Result = RecurrenceDialogResult.Ok Then ' Reassign the 'recurrence' stack variable to now ' reference the instance that resulted from the dialog session. recurrence = dialog.DateRecurrence ' Get the first 10 occurrences generated by the recurrence Dim occurrenceDates As List(Of DateTime) = New List(Of DateTime)(10) Dim startDate As DateTime = DateTime.Today While occurrenceDates.Count < 10 Dim nextOccurrence As Nullable(Of DateTime) = recurrence.GetDateOfNextOccurrence(startDate) If nextOccurrence.HasValue Then occurrenceDates.Add(nextOccurrence.Value) startDate = nextOccurrence.Value.AddDays(1) If (startDate > recurrence.RangeEndDate) Then Exit While Else Exit While End If End While ' Display a human-readable description of the recurrence ' along with the dates of the first 10 occurrences in a MessageBox Dim sb As New StringBuilder() sb.AppendLine(recurrence.Description) sb.AppendLine(Environment.NewLine) ' List the first 10 occurrences sb.AppendLine(String.Format("The first {0} occurrences are:", occurrenceDates.Count)) sb.AppendLine(Environment.NewLine) Dim occurrenceDate As DateTime For Each occurrenceDate In occurrenceDates sb.AppendLine(occurrenceDate.ToShortDateString()) Next ' Show the MessageBox. MessageBox.Show(sb.ToString(), recurrence.ToString(), MessageBoxButtons.OK) End If End Sub
using System.Collections.Generic; using Infragistics.Win; using Infragistics.Win.UltraWinSchedule; using System.Diagnostics; private void button1_Click(object sender, EventArgs e) { // Create a new DateRecurrence on which the dialog session will be based. DateRecurrence recurrence = new DateRecurrence( new DateTime(DateTime.Today.Year, 1, 1) ); recurrence.RangeEndDate = new DateTime(DateTime.Today.Year, 12, 31); // Create and show the RecurrenceDialog in DateRecurrence mode RecurrenceDialog dialog = new RecurrenceDialog( recurrence ); dialog.ShowDialog(); // If the dialog session was not canceled... if ( dialog.Result == RecurrenceDialogResult.Ok ) { // Reassign the 'recurrence' stack variable to now // reference the instance that resulted from the dialog session. recurrence = dialog.DateRecurrence; // Get the first 10 occurrences generated by the recurrence List<DateTime> occurrenceDates = new List<DateTime>(10); DateTime startDate = DateTime.Today; while ( occurrenceDates.Count < 10 ) { Nullable<DateTime> nextOccurrence = recurrence.GetDateOfNextOccurrence( startDate ); if ( nextOccurrence.HasValue ) { occurrenceDates.Add( nextOccurrence.Value ); startDate = nextOccurrence.Value.AddDays(1); if ( startDate > recurrence.RangeEndDate ) break; } else break; } // Display a human-readable description of the recurrence // along with the dates of the first 10 occurrences in a MessageBox StringBuilder sb = new StringBuilder(); sb.AppendLine( recurrence.Description ); sb.AppendLine( Environment.NewLine ); // List the first 10 occurrences sb.AppendLine( string.Format("The first {0} occurrences are:", occurrenceDates.Count) ); sb.AppendLine( Environment.NewLine ); foreach( DateTime occurrenceDate in occurrenceDates ) { sb.AppendLine( occurrenceDate.ToShortDateString() ); } // Show the MessageBox. MessageBox.Show( sb.ToString(), recurrence.ToString(), MessageBoxButtons.OK ); } }
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