'宣言 Public ReadOnly Property AlternateSelectedDateRanges As SelectedDateRanges
public SelectedDateRanges AlternateSelectedDateRanges {get;}
この選択リストは SelectedDateRanges プロパティによって返されるリストとは別のものであり、SelectedDateRangesのリストとは関係ありません。UseAlternateSelectedDateRanges プロパティがTrueに設定されているコントロールは、 SelectedDateRanges プロパティによって返されるリストの代わりにこの選択リストを使用します。AlternateSelectedDateRangesプロパティによって、選択された日の個別のセットを維持しながら、関連付けられた UltraCalendarInfo コンポーネントによって提供されたすべてのその他の情報をコントロールが共有することを可能にします。
Imports Infragistics.Win Imports Infragistics.Win.UltraWinSchedule Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click ' Set the UltraMonthViewMulti control's UseAlternateSelectedDateRanges ' property to true so that when dates are selected, the UltraDayView, ' UltraWeekView, and UltraMonthViewSingle controls do NOT automatically ' reflect those changes. Me.ultraMonthViewMulti1.UseAlternateSelectedDateRanges = True ' Set the UltraCalendarInfo's AlternateSelectTypeDay property to 'Extended' ' so that multiple days can be selected in the alternate collection, and ' restrict the total number of days that can be selected in the alternate ' collection to 31. Me.ultraCalendarInfo1.AlternateSelectTypeDay = SelectType.Extended Me.ultraCalendarInfo1.MaxSelectedDays = 31 End Sub Private Sub ultraCalendarInfo1_AfterAlternateSelectedDateRangeChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles ultraCalendarInfo1.AfterAlternateSelectedDateRangeChange ' Resume painting for the UltraDayView, UltraWeekView, and ' UltraMonthViewSingle controls. Me.ultraDayView1.EndUpdate() Me.ultraWeekView1.EndUpdate() Me.ultraMonthViewSingle1.EndUpdate() If (Me.ultraDayView1.Visible) Then Me.ultraDayView1.Refresh() ElseIf (Me.ultraWeekView1.Visible) Then Me.ultraWeekView1.Refresh() ElseIf (Me.ultraMonthViewSingle1.Visible) Then Me.ultraMonthViewSingle1.Refresh() End If End Sub Private Sub ultraCalendarInfo1_BeforeAlternateSelectedDateRangeChange(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinSchedule.BeforeSelectedDateRangeChangeEventArgs) Handles ultraCalendarInfo1.BeforeAlternateSelectedDateRangeChange Dim selection As SelectedDateRanges = e.NewSelectedDateRanges ' Get the total number of days that were selected. Dim totalDaysSelected As Integer = selection.SelectedDaysCount ' Return if nothing was selected. If totalDaysSelected = 0 Then Return ' Suspend painting for the UltraDayView, UltraWeekView, and ' UltraMonthViewSingle controls while we process the change ' in date selection. Me.ultraDayView1.BeginUpdate() Me.ultraWeekView1.BeginUpdate() Me.ultraMonthViewSingle1.BeginUpdate() ' Determine whether we have a discontiguous selection...since the ' AlternateSelectedDateRanges collection automatically handles ' defragmentation of contiguous selected days, the count of the collection ' will only exceed one if all selected days cannot be expressed by one ' DateRange object. Dim isDiscontiguous As Boolean = selection.Count > 1 ' Get the first and last dates in the date selection. Dim firstDateInSelection As DateTime = DateTime.MinValue Dim lastDateInSelection As DateTime = DateTime.MaxValue Dim i As Integer For i = 0 To selection.Count - 1 Dim dateRange As DateRange = selection(i) If i = 0 Then firstDateInSelection = DateRange.StartDate If i = (selection.Count - 1) Then lastDateInSelection = dateRange.EndDate Next ' Determine whether the first day of the week is the first day in the selection Dim firstDayOfWeekBeginsSelection As Boolean = firstDateInSelection.DayOfWeek = Me.ultraCalendarInfo1.FirstDayOfWeek Or Me.ultraCalendarInfo1.FirstDayOfWeek = FirstDayOfWeek.Default ' Analyze the selection and determine which schedule control should be displayed. Dim controlToDisplay As UltraScheduleControlBase = Me.ultraMonthViewSingle1 If totalDaysSelected <= 14 Then controlToDisplay = Me.ultraDayView1 If firstDayOfWeekBeginsSelection Then If (totalDaysSelected = 7) Then controlToDisplay = Me.ultraWeekView1 If (totalDaysSelected = 14) Then controlToDisplay = Me.ultraMonthViewSingle1 End If End If If controlToDisplay Is Me.ultraMonthViewSingle1 Then Me.ultraMonthViewSingle1.VisibleWeeks = totalDaysSelected / 7 ElseIf controlToDisplay Is Me.ultraDayView1 Then Me.ultraDayView1.CalendarInfo.SelectedDateRanges.Clear() For i = 0 To selection.Count - 1 Dim dateRange As DateRange = selection(i) Me.ultraDayView1.CalendarInfo.SelectedDateRanges.Add(dateRange.StartDate, dateRange.EndDate) Next End If Me.DisplayScheduleControl(controlToDisplay) End Sub Private Sub DisplayScheduleControl(ByVal control As UltraScheduleControlBase) Me.ultraDayView1.Visible = False Me.ultraWeekView1.Visible = False Me.ultraMonthViewSingle1.Visible = False control.Visible = True control.Dock = DockStyle.Fill End Sub
using Infragistics.Win; using Infragistics.Win.UltraWinSchedule; using System.Diagnostics; private void button1_Click(object sender, System.EventArgs e) { // Set the UltraMonthViewMulti control's UseAlternateSelectedDateRanges // property to true so that when dates are selected, the UltraDayView, // UltraWeekView, and UltraMonthViewSingle controls do NOT automatically // reflect those changes. this.ultraMonthViewMulti1.UseAlternateSelectedDateRanges = true; // Set the UltraCalendarInfo's AlternateSelectTypeDay property to 'Extended' // so that multiple days can be selected in the alternate collection, and // restrict the total number of days that can be selected in the alternate // collection to 31. this.ultraCalendarInfo1.AlternateSelectTypeDay = SelectType.Extended; this.ultraCalendarInfo1.MaxSelectedDays = 31; } private void ultraCalendarInfo1_AfterAlternateSelectedDateRangeChange(object sender, System.EventArgs e) { // Resume painting for the UltraDayView, UltraWeekView, and // UltraMonthViewSingle controls. this.ultraDayView1.EndUpdate(); this.ultraWeekView1.EndUpdate(); this.ultraMonthViewSingle1.EndUpdate(); if ( this.ultraDayView1.Visible ) this.ultraDayView1.Refresh(); else if ( this.ultraWeekView1.Visible ) this.ultraWeekView1.Refresh(); else if ( this.ultraMonthViewSingle1.Visible ) this.ultraMonthViewSingle1.Refresh(); } private void ultraCalendarInfo1_BeforeAlternateSelectedDateRangeChange(object sender, Infragistics.Win.UltraWinSchedule.BeforeSelectedDateRangeChangeEventArgs e) { SelectedDateRanges selection = e.NewSelectedDateRanges; // Get the total number of days that were selected. int totalDaysSelected = selection.SelectedDaysCount; // Return if nothing was selected. if ( totalDaysSelected == 0 ) return; // Suspend painting for the UltraDayView, UltraWeekView, and // UltraMonthViewSingle controls while we process the change // in date selection. this.ultraDayView1.BeginUpdate(); this.ultraWeekView1.BeginUpdate(); this.ultraMonthViewSingle1.BeginUpdate(); // Determine whether we have a discontiguous selection...since the // AlternateSelectedDateRanges collection automatically handles // defragmentation of contiguous selected days, the count of the collection // will only exceed one if all selected days cannot be expressed by one // DateRange object. bool isDiscontiguous = selection.Count > 1; // Get the first and last dates in the date selection. DateTime firstDateInSelection = DateTime.MinValue; DateTime lastDateInSelection = DateTime.MaxValue; for ( int i = 0; i < selection.Count; i ++ ) { DateRange dateRange = selection[i]; if ( i == 0 ) firstDateInSelection = dateRange.StartDate; if ( i == (selection.Count - 1) ) lastDateInSelection = dateRange.EndDate; } // Determine whether the first day of the week is the first day in the selection bool firstDayOfWeekBeginsSelection = ( (int)firstDateInSelection.DayOfWeek == (int)this.ultraCalendarInfo1.FirstDayOfWeek || this.ultraCalendarInfo1.FirstDayOfWeek == FirstDayOfWeek.Default ); // Analyze the selection and determine which schedule control should be displayed. UltraScheduleControlBase controlToDisplay = this.ultraMonthViewSingle1; if ( totalDaysSelected <= 14 ) { controlToDisplay = this.ultraDayView1; if ( firstDayOfWeekBeginsSelection ) { if ( totalDaysSelected == 7 ) controlToDisplay = this.ultraWeekView1; else if ( totalDaysSelected == 14 ) controlToDisplay = this.ultraMonthViewSingle1; } } if ( controlToDisplay == this.ultraMonthViewSingle1 ) this.ultraMonthViewSingle1.VisibleWeeks = (int)(totalDaysSelected / 7); else if ( controlToDisplay == this.ultraDayView1 ) { this.ultraDayView1.CalendarInfo.SelectedDateRanges.Clear(); for ( int i = 0; i < selection.Count; i ++ ) { DateRange dateRange = selection[i]; this.ultraDayView1.CalendarInfo.SelectedDateRanges.Add( dateRange.StartDate, dateRange.EndDate ); } } this.DisplayScheduleControl( controlToDisplay ); } private void DisplayScheduleControl( UltraScheduleControlBase control ) { this.ultraDayView1.Visible = false; this.ultraWeekView1.Visible = false; this.ultraMonthViewSingle1.Visible = false; control.Visible = true; control.Dock = DockStyle.Fill; }