通常、1 日の長さは 24 時間です。LogicalDayDurationプロパティを使用すると、1 日の論理的な長さを短縮することができます。
LogicalDayDuration プロパティは 1 分未満、または24時間超の値には設定できません。そうすると、例外がスローされます。
Imports Infragistics.Win Imports Infragistics.Win.UltraWinSchedule Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim now As DateTime = DateTime.Now ' Create a TimeSpan that contains the same number of hours ' as the offset of the current time from midnight. Dim offset As TimeSpan = TimeSpan.FromHours(now.Hour) ' Create a TimeSpan that contains the number of hours remaining ' in the current day, including the current hour. Dim duration As TimeSpan = TimeSpan.FromHours((24 - now.Hour)) ' Assign the offset to the UltraCalendarInfo's LogicalDayOffset ' property, so that the logical day begins on the current hour. Me.ultraCalendarInfo1.LogicalDayOffset = offset ' Assign the duration to the UltraCalendarInfo's LogicalDayDuration property, ' so that the logical day ends at midnight of the following day. Me.ultraCalendarInfo1.LogicalDayDuration = duration End Sub
using Infragistics.Win; using Infragistics.Win.UltraWinSchedule; using System.Diagnostics; private void button1_Click(object sender, System.EventArgs e) { DateTime now = DateTime.Now; // Create a TimeSpan that contains the same number of hours // as the offset of the current time from midnight. TimeSpan offset = TimeSpan.FromHours( (double)now.Hour ); // Create a TimeSpan that contains the number of hours remaining // in the current day, including the current hour. TimeSpan duration = TimeSpan.FromHours( (double)(24 - now.Hour) ); // Assign the offset to the UltraCalendarInfo's LogicalDayOffset // property, so that the logical day begins on the current hour. this.ultraCalendarInfo1.LogicalDayOffset = offset; // Assign the duration to the UltraCalendarInfo's LogicalDayDuration property, // so that the logical day ends at midnight of the following day. this.ultraCalendarInfo1.LogicalDayDuration = duration; }